@alizarin/napi 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/Cargo.toml +21 -0
- package/__test__/index.mjs +533 -0
- package/alizarin-napi.linux-x64-gnu.node +0 -0
- package/bin/csv-to-prebuild.mjs +143 -0
- package/build.rs +5 -0
- package/index.d.ts +329 -0
- package/index.js +334 -0
- package/package.json +32 -0
- package/src/instance_wrapper_napi.rs +1699 -0
- package/src/lib.rs +611 -0
package/build.rs
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Build a StaticGraph from model CSVs (graph.csv, nodes.csv, optional collections.csv).
|
|
8
|
+
*
|
|
9
|
+
* Returns the graph as a JSON string. The `rdm_namespace` is used for
|
|
10
|
+
* deterministic ID generation (typically a UUID or URL).
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildGraphFromCsvs(graphCsv: string, nodesCsv: string, collectionsCsv: string | undefined | null, rdmNamespace: string): any
|
|
13
|
+
/**
|
|
14
|
+
* Build StaticResources from a business data CSV, given a graph JSON string
|
|
15
|
+
* and collections JSON string (as returned by `buildGraphFromCsvs`).
|
|
16
|
+
*
|
|
17
|
+
* Returns the resources wrapped in the `{ business_data: { resources: [...] } }`
|
|
18
|
+
* format expected by PrebuildLoader.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildBusinessDataFromCsv(csvData: string, graphJson: string, collectionsJson: string): any
|
|
21
|
+
/**
|
|
22
|
+
* Coerce a value using the registered extension handler for the given datatype.
|
|
23
|
+
*
|
|
24
|
+
* Returns `{ tileData, displayValue }` or null if no handler is registered.
|
|
25
|
+
*/
|
|
26
|
+
export declare function extensionCoerce(datatype: string, value: any, config?: any | undefined | null): any | null
|
|
27
|
+
/**
|
|
28
|
+
* Render a display string for tile data using the extension handler.
|
|
29
|
+
*
|
|
30
|
+
* Returns the display string, or null if no handler or no display.
|
|
31
|
+
*/
|
|
32
|
+
export declare function extensionRenderDisplay(datatype: string, tileData: any, language: string): string | null
|
|
33
|
+
/**
|
|
34
|
+
* Resolve markers in tile data using the extension handler.
|
|
35
|
+
*
|
|
36
|
+
* Returns the resolved tile data value.
|
|
37
|
+
*/
|
|
38
|
+
export declare function extensionResolveMarkers(datatype: string, tileData: any, language: string): any
|
|
39
|
+
/** Check if an extension handler is registered for the given datatype. */
|
|
40
|
+
export declare function hasExtensionHandler(datatype: string): boolean
|
|
41
|
+
/** List all registered extension handler datatypes. */
|
|
42
|
+
export declare function getRegisteredExtensionHandlers(): Array<string>
|
|
43
|
+
export declare class NapiRdmCache {
|
|
44
|
+
constructor()
|
|
45
|
+
/** Load collections from a SKOS JSON string. */
|
|
46
|
+
loadFromSkosJson(jsonStr: string): void
|
|
47
|
+
/** Load a single collection from JSON. */
|
|
48
|
+
loadCollectionJson(jsonStr: string): void
|
|
49
|
+
get collectionCount(): number
|
|
50
|
+
}
|
|
51
|
+
export declare class NapiNodeConfigManager {
|
|
52
|
+
constructor()
|
|
53
|
+
/** Build node configs from a graph JSON string. */
|
|
54
|
+
buildFromGraphJson(graphJson: string): void
|
|
55
|
+
/** Build node configs from a NapiStaticGraph. */
|
|
56
|
+
buildFromGraph(graph: NapiStaticGraph): void
|
|
57
|
+
}
|
|
58
|
+
export declare class NapiPseudoValue {
|
|
59
|
+
get node(): any
|
|
60
|
+
get nodeId(): string | null
|
|
61
|
+
get nodeAlias(): string | null
|
|
62
|
+
get datatype(): string
|
|
63
|
+
get nodegroupId(): string | null
|
|
64
|
+
get isCollector(): boolean
|
|
65
|
+
get independent(): boolean
|
|
66
|
+
get exportable(): boolean
|
|
67
|
+
get isrequired(): boolean
|
|
68
|
+
get issearchable(): boolean
|
|
69
|
+
get ontologyclass(): any
|
|
70
|
+
get hascustomalias(): boolean
|
|
71
|
+
get parentproperty(): string | null
|
|
72
|
+
get description(): any
|
|
73
|
+
get name(): any
|
|
74
|
+
get tileId(): string | null
|
|
75
|
+
get tileData(): any
|
|
76
|
+
get valueLoaded(): boolean
|
|
77
|
+
hasTileData(): boolean
|
|
78
|
+
setTileData(value: any): void
|
|
79
|
+
get childNodeAliases(): any
|
|
80
|
+
getChildNodeId(index: number): string | null
|
|
81
|
+
isIterable(): boolean
|
|
82
|
+
/** Get sortorder from the tile */
|
|
83
|
+
get sortorder(): any
|
|
84
|
+
/** Snapshot all properties in one call (avoids multiple N-API boundary crossings) */
|
|
85
|
+
toSnapshot(): any
|
|
86
|
+
/** Clear tile data */
|
|
87
|
+
clear(): void
|
|
88
|
+
}
|
|
89
|
+
export declare class NapiPseudoList {
|
|
90
|
+
get nodeAlias(): string
|
|
91
|
+
get totalValues(): number
|
|
92
|
+
get isLoaded(): boolean
|
|
93
|
+
get isSingle(): boolean
|
|
94
|
+
isIterable(): boolean
|
|
95
|
+
getValue(valueIndex: number): NapiPseudoValue | null
|
|
96
|
+
getAllValues(): Array<NapiPseudoValue>
|
|
97
|
+
}
|
|
98
|
+
export declare class NapiPopulateResult {
|
|
99
|
+
getValueAliases(): Array<string>
|
|
100
|
+
getValue(alias: string): NapiPseudoList | null
|
|
101
|
+
/** Get all values as a JSON map (single boundary crossing). */
|
|
102
|
+
getAllValues(): any
|
|
103
|
+
get allValuesMap(): any
|
|
104
|
+
get allNodegroupsMap(): any
|
|
105
|
+
}
|
|
106
|
+
export declare class NapiEnsureNodegroupResult {
|
|
107
|
+
getValueAliases(): Array<string>
|
|
108
|
+
getValue(alias: string): NapiPseudoList | null
|
|
109
|
+
getAllValues(): any
|
|
110
|
+
get impliedNodegroups(): Array<string>
|
|
111
|
+
get allNodegroupsMap(): any
|
|
112
|
+
}
|
|
113
|
+
export declare class NapiValuesFromNodegroupResult {
|
|
114
|
+
getAllValues(): any
|
|
115
|
+
get impliedNodegroups(): Array<string>
|
|
116
|
+
}
|
|
117
|
+
export declare class NapiResourceInstanceWrapper {
|
|
118
|
+
/** Create a wrapper for a given graph (must be registered). */
|
|
119
|
+
constructor(graphId: string)
|
|
120
|
+
/** Load tiles from a JSON array. */
|
|
121
|
+
loadTiles(tilesJs: any): void
|
|
122
|
+
/** Load tiles directly from a StaticResource JSON. */
|
|
123
|
+
loadTilesFromResource(resourceJs: any): void
|
|
124
|
+
/** Append tiles incrementally (for lazy loading). */
|
|
125
|
+
appendTiles(tilesJs: any): void
|
|
126
|
+
getTileCount(): number
|
|
127
|
+
/**
|
|
128
|
+
* Export all tiles as a JSON string.
|
|
129
|
+
* Returns the wrapper's current tile state (including any mutations from setTileDataForNode).
|
|
130
|
+
* Returned as a string for fast boundary crossing — call JSON.parse() on the JS side.
|
|
131
|
+
*/
|
|
132
|
+
exportTilesJson(): string
|
|
133
|
+
/** Prune tiles to only keep those in permitted nodegroups. */
|
|
134
|
+
pruneResourceTiles(): void
|
|
135
|
+
tilesLoaded(): boolean
|
|
136
|
+
getAllTileIds(): Array<string>
|
|
137
|
+
getTileIdsByNodegroup(nodegroupId?: string | undefined | null): Array<string>
|
|
138
|
+
getTile(tileId: string): any
|
|
139
|
+
getTileData(tileId: string, nodeId: string): any
|
|
140
|
+
/**
|
|
141
|
+
* Set a single node's data in a tile, mutating in place.
|
|
142
|
+
* Returns true if the tile was found and updated.
|
|
143
|
+
*/
|
|
144
|
+
setTileDataForNode(tileId: string, nodeId: string, value: any): boolean
|
|
145
|
+
hasTilesForNodegroup(nodegroupId: string): boolean
|
|
146
|
+
getNodegroupCount(): number
|
|
147
|
+
setLazy(lazy: boolean): void
|
|
148
|
+
isNodegroupLoaded(nodegroupId?: string | undefined | null): boolean
|
|
149
|
+
isNodegroupLoadedOrLoading(nodegroupId?: string | undefined | null): boolean
|
|
150
|
+
tryAcquireNodegroupLock(nodegroupId: string): boolean
|
|
151
|
+
getMissingNodegroupsForChildren(parentNodeId: string): Array<string>
|
|
152
|
+
getResourceId(): string | null
|
|
153
|
+
getName(): any
|
|
154
|
+
getDescriptors(recompute: boolean): any
|
|
155
|
+
/** Populate the pseudo cache for the given nodegroups. */
|
|
156
|
+
populate(lazy: boolean, nodegroupIds: Array<string>, rootNodeAlias: string): NapiPopulateResult
|
|
157
|
+
/** Ensure a single nodegroup is loaded and return structured values. */
|
|
158
|
+
ensureNodegroup(allValuesJs: any, allNodegroupsJs: any, nodegroupId: string, addIfMissing: boolean, nodegroupPermissionsJs: any, doImpliedNodegroups: boolean): NapiEnsureNodegroupResult
|
|
159
|
+
/** Build pseudo values from tiles for a specific nodegroup. */
|
|
160
|
+
valuesFromResourceNodegroup(existingValuesJs: any, nodegroupTileIds: Array<string>, nodegroupId: string): NapiValuesFromNodegroupResult
|
|
161
|
+
/** Resolve a dot-separated path and return a PseudoList. */
|
|
162
|
+
getValuesAtPath(path: string): NapiPseudoList
|
|
163
|
+
/** Get semantic child value for a parent/child relationship. */
|
|
164
|
+
getSemanticChildValue(parentTileId: string | undefined | null, parentNodeId: string, parentNodegroupId: string | undefined | null, childAlias: string): any
|
|
165
|
+
/** Get all semantic child values for a parent node. */
|
|
166
|
+
getAllSemanticChildValues(parentTileId: string | undefined | null, parentNodeId: string, parentNodegroupId?: string | undefined | null): any
|
|
167
|
+
/** Find all semantic children of a parent node (returns map of alias → tile IDs). */
|
|
168
|
+
findSemanticChildren(parentTileId: string | undefined | null, parentNodeId: string, parentNodegroupId?: string | undefined | null): any
|
|
169
|
+
getCachedPseudo(alias?: string | undefined | null): NapiPseudoList | null
|
|
170
|
+
getRootPseudo(): NapiPseudoValue | null
|
|
171
|
+
cachePseudoList(alias: string, list: NapiPseudoList): void
|
|
172
|
+
cachePseudoValue(alias: string, value: NapiPseudoValue): void
|
|
173
|
+
clearPseudoCache(): void
|
|
174
|
+
/** Construct a PseudoValue from node metadata (for TS wrapper). */
|
|
175
|
+
makePseudoValue(alias: string, tileId: string | undefined | null, isPermitted: boolean, isSingle: boolean): any
|
|
176
|
+
/** Serialize to JSON (tile_data mode — raw values). */
|
|
177
|
+
toJson(): any
|
|
178
|
+
/** Serialize to display JSON (resolved labels). */
|
|
179
|
+
toDisplayJson(rdmCache: NapiRdmCache, nodeConfigManager: NapiNodeConfigManager, language?: string | undefined | null): any
|
|
180
|
+
/** Serialize to display JSON without RDM/config (basic labels only). */
|
|
181
|
+
toDisplayJsonSimple(language?: string | undefined | null): any
|
|
182
|
+
release(): void
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* NAPI equivalent of WASMResourceModelWrapper.
|
|
186
|
+
*
|
|
187
|
+
* Provides graph schema access (nodes, edges, nodegroups, permissions, pruning)
|
|
188
|
+
* so that the TS ResourceModelWrapper can delegate to either this or the WASM
|
|
189
|
+
* model wrapper via the backend abstraction.
|
|
190
|
+
*/
|
|
191
|
+
export declare class NapiResourceModelWrapper {
|
|
192
|
+
/**
|
|
193
|
+
* Create a model wrapper from a graph JSON string.
|
|
194
|
+
*
|
|
195
|
+
* The graph is also registered in the core GRAPH_REGISTRY so that
|
|
196
|
+
* NapiResourceInstanceWrapper can look it up by graph_id.
|
|
197
|
+
*/
|
|
198
|
+
constructor(graphJson: string, defaultAllow: boolean)
|
|
199
|
+
/** Create from an already-loaded NapiStaticGraph. */
|
|
200
|
+
static fromGraph(graph: NapiStaticGraph, defaultAllow: boolean): NapiResourceModelWrapper
|
|
201
|
+
getGraphId(): string
|
|
202
|
+
get graph(): any
|
|
203
|
+
set graph(graphJson: string)
|
|
204
|
+
buildNodes(): void
|
|
205
|
+
buildNodesForGraph(graphJson: string): void
|
|
206
|
+
/** Get the root node of the graph. */
|
|
207
|
+
getRootNode(): any
|
|
208
|
+
/** Get all nodes as a Map<string, StaticNode>. */
|
|
209
|
+
getNodeObjects(): Record<string, any>
|
|
210
|
+
/** Get all nodes indexed by alias. */
|
|
211
|
+
getNodeObjectsByAlias(): Record<string, any>
|
|
212
|
+
/** Get a single node by alias. */
|
|
213
|
+
getNodeObjectFromAlias(alias: string): any
|
|
214
|
+
/** Get a single node by node ID. */
|
|
215
|
+
getNodeObjectFromId(id: string): any
|
|
216
|
+
/** Get child nodes for a parent node ID. */
|
|
217
|
+
getChildNodes(nodeId: string): Record<string, any>
|
|
218
|
+
/** Get child node aliases (just strings, not full objects). */
|
|
219
|
+
getChildNodeAliases(nodeId: string): Array<string>
|
|
220
|
+
/** Get edges as Map<parent_id, [child_ids]>. */
|
|
221
|
+
getEdges(): Record<string, Array<string>>
|
|
222
|
+
/** Get all nodegroups. */
|
|
223
|
+
getNodegroupObjects(): Record<string, any>
|
|
224
|
+
/** Get nodegroup IDs. */
|
|
225
|
+
getNodegroupIds(): Array<string>
|
|
226
|
+
/** Get nodegroup name (actually the name of the root node for that nodegroup). */
|
|
227
|
+
getNodegroupName(nodegroupId: string): string
|
|
228
|
+
/** Get node ID from alias. */
|
|
229
|
+
getNodeIdFromAlias(alias: string): string
|
|
230
|
+
get nodes(): Record<string, any>
|
|
231
|
+
get nodesByAlias(): Record<string, any>
|
|
232
|
+
get edges(): Record<string, Array<string>>
|
|
233
|
+
get nodegroups(): Record<string, any>
|
|
234
|
+
/** Get permitted nodegroups as boolean map. */
|
|
235
|
+
getPermittedNodegroups(): Record<string, boolean>
|
|
236
|
+
/** Check if a nodegroup is permitted. */
|
|
237
|
+
isNodegroupPermitted(nodegroupId: string): boolean
|
|
238
|
+
/**
|
|
239
|
+
* Set permitted nodegroups. Accepts an object with boolean values or
|
|
240
|
+
* conditional rule objects { path, allowed }.
|
|
241
|
+
*/
|
|
242
|
+
setPermittedNodegroups(permissions: any): void
|
|
243
|
+
setDefaultAllowAllNodegroups(defaultAllow: boolean): void
|
|
244
|
+
setGraphNodes(nodesJson: string): void
|
|
245
|
+
setGraphEdges(edgesJson: string): void
|
|
246
|
+
setGraphNodegroups(nodegroupsJson: string): void
|
|
247
|
+
/** Prune graph to only include permitted nodegroups and their dependencies. */
|
|
248
|
+
pruneGraph(keepFunctions?: Array<string> | undefined | null): void
|
|
249
|
+
}
|
|
250
|
+
export declare class NapiPrebuildLoader {
|
|
251
|
+
constructor(path: string)
|
|
252
|
+
/** Load a single graph from a JSON file path (relative to prebuild root or absolute). */
|
|
253
|
+
loadGraph(path: string): NapiStaticGraph
|
|
254
|
+
/** Load all graphs from prebuild/graphs/resource_models/ */
|
|
255
|
+
loadAllGraphs(): Array<NapiStaticGraph>
|
|
256
|
+
/**
|
|
257
|
+
* Load full resources (with tiles) from a single business data file,
|
|
258
|
+
* filtered by graph ID.
|
|
259
|
+
*/
|
|
260
|
+
loadFullResourcesFromFile(path: string, graphId: string): any
|
|
261
|
+
/** Find all business data JSON files in the prebuild directory. */
|
|
262
|
+
findBusinessDataFiles(): Array<string>
|
|
263
|
+
/** Get prebuild directory info. */
|
|
264
|
+
getInfo(): any
|
|
265
|
+
/** Count resources for a given graph ID. */
|
|
266
|
+
countResourcesForGraph(graphId: string): number
|
|
267
|
+
}
|
|
268
|
+
export declare class NapiPrebuildExporter {
|
|
269
|
+
constructor()
|
|
270
|
+
/**
|
|
271
|
+
* Export registered graphs to a directory.
|
|
272
|
+
*
|
|
273
|
+
* Classifies graphs as resource_models or branches based on `isresource`,
|
|
274
|
+
* writes as `{"graph": [graph_data]}` JSON files with sorted keys.
|
|
275
|
+
*/
|
|
276
|
+
exportGraphs(graphIds: Array<string>, outDir: string): Array<string>
|
|
277
|
+
/** Export all registered graphs to a directory. */
|
|
278
|
+
exportAllGraphs(outDir: string): Array<string>
|
|
279
|
+
/**
|
|
280
|
+
* Build complete export data as JSON (without writing to filesystem).
|
|
281
|
+
*
|
|
282
|
+
* Returns an object with `files` array of `{relativePath, content}` entries.
|
|
283
|
+
*/
|
|
284
|
+
buildExportData(graphIds: Array<string> | undefined | null, baseUri: string): any
|
|
285
|
+
/** Get IDs of all registered graphs. */
|
|
286
|
+
getRegisteredGraphIds(): Array<string>
|
|
287
|
+
}
|
|
288
|
+
export declare class NapiStaticGraph {
|
|
289
|
+
/** Parse a graph from a JSON string (the file content, not a file path). */
|
|
290
|
+
static fromJsonString(jsonStr: string): NapiStaticGraph
|
|
291
|
+
get graphId(): string
|
|
292
|
+
get name(): any
|
|
293
|
+
/** Register this graph in the global registry so NapiResourceInstanceWrapper can use it. */
|
|
294
|
+
register(): void
|
|
295
|
+
}
|
|
296
|
+
export declare class NapiStaticResourceRegistry {
|
|
297
|
+
constructor()
|
|
298
|
+
/** Insert full resources (with tiles) from a JSON array of StaticResource. */
|
|
299
|
+
mergeFromResourcesJson(resourcesJson: string, storeFull?: boolean | undefined | null): void
|
|
300
|
+
/**
|
|
301
|
+
* Load a business_data file from raw bytes (Buffer), parse entirely in Rust,
|
|
302
|
+
* merge into this registry, and return lightweight refs.
|
|
303
|
+
*
|
|
304
|
+
* Equivalent to the WASM `loadFromBusinessDataBytes` but runs natively —
|
|
305
|
+
* no WASM linear memory limit, and panics produce real stack traces.
|
|
306
|
+
*/
|
|
307
|
+
loadFromBusinessDataBytes(bytes: Buffer, storeFull?: boolean | undefined | null, includeCaches?: boolean | undefined | null): Array<any>
|
|
308
|
+
/** Insert full resources from a business_data JSON file string. */
|
|
309
|
+
mergeFromBusinessDataJson(businessDataJson: string, storeFull?: boolean | undefined | null): void
|
|
310
|
+
/** Build an inverted index: visibility value -> [resource IDs]. */
|
|
311
|
+
getValueToResourcesIndex(graph: NapiStaticGraph, nodeIdentifier: string, flattenLocalized?: boolean | undefined | null): Record<string, Array<string>>
|
|
312
|
+
/**
|
|
313
|
+
* Extract values from one node in tiles where another node matches a filter.
|
|
314
|
+
*
|
|
315
|
+
* Both nodes must be in the same nodegroup. Returns raw JSON values from
|
|
316
|
+
* the extract node for each tile where the filter node's display value
|
|
317
|
+
* contains any of the filter values.
|
|
318
|
+
*/
|
|
319
|
+
getFilteredTileValues(graph: NapiStaticGraph, filterNode: string, filterValues: Array<string>, extractNode: string, flattenLocalized?: boolean | undefined | null, requiredScope?: string | undefined | null): any
|
|
320
|
+
/** Build a forward index: resource ID -> [node values]. */
|
|
321
|
+
getNodeValuesIndex(graph: NapiStaticGraph, nodeIdentifier: string): any
|
|
322
|
+
get length(): number
|
|
323
|
+
contains(resourceId: string): boolean
|
|
324
|
+
hasFull(resourceId: string): boolean
|
|
325
|
+
/** Get the full resource (with tiles) as a JSON object, or null if only summary stored. */
|
|
326
|
+
getFull(resourceId: string): any | null
|
|
327
|
+
/** Get a summary for a resource (works for both summary and full entries), or null if unknown. */
|
|
328
|
+
getSummary(resourceId: string): any | null
|
|
329
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
7
|
+
const { existsSync, readFileSync } = require('fs')
|
|
8
|
+
const { join } = require('path')
|
|
9
|
+
|
|
10
|
+
const { platform, arch } = process
|
|
11
|
+
|
|
12
|
+
let nativeBinding = null
|
|
13
|
+
let localFileExisted = false
|
|
14
|
+
let loadError = null
|
|
15
|
+
|
|
16
|
+
function isMusl() {
|
|
17
|
+
// For Node 10
|
|
18
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
19
|
+
try {
|
|
20
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
21
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
+
return !glibcVersionRuntime
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
switch (platform) {
|
|
32
|
+
case 'android':
|
|
33
|
+
switch (arch) {
|
|
34
|
+
case 'arm64':
|
|
35
|
+
localFileExisted = existsSync(join(__dirname, 'alizarin-napi.android-arm64.node'))
|
|
36
|
+
try {
|
|
37
|
+
if (localFileExisted) {
|
|
38
|
+
nativeBinding = require('./alizarin-napi.android-arm64.node')
|
|
39
|
+
} else {
|
|
40
|
+
nativeBinding = require('@alizarin/napi-android-arm64')
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
loadError = e
|
|
44
|
+
}
|
|
45
|
+
break
|
|
46
|
+
case 'arm':
|
|
47
|
+
localFileExisted = existsSync(join(__dirname, 'alizarin-napi.android-arm-eabi.node'))
|
|
48
|
+
try {
|
|
49
|
+
if (localFileExisted) {
|
|
50
|
+
nativeBinding = require('./alizarin-napi.android-arm-eabi.node')
|
|
51
|
+
} else {
|
|
52
|
+
nativeBinding = require('@alizarin/napi-android-arm-eabi')
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
loadError = e
|
|
56
|
+
}
|
|
57
|
+
break
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
60
|
+
}
|
|
61
|
+
break
|
|
62
|
+
case 'win32':
|
|
63
|
+
switch (arch) {
|
|
64
|
+
case 'x64':
|
|
65
|
+
localFileExisted = existsSync(
|
|
66
|
+
join(__dirname, 'alizarin-napi.win32-x64-msvc.node')
|
|
67
|
+
)
|
|
68
|
+
try {
|
|
69
|
+
if (localFileExisted) {
|
|
70
|
+
nativeBinding = require('./alizarin-napi.win32-x64-msvc.node')
|
|
71
|
+
} else {
|
|
72
|
+
nativeBinding = require('@alizarin/napi-win32-x64-msvc')
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadError = e
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
case 'ia32':
|
|
79
|
+
localFileExisted = existsSync(
|
|
80
|
+
join(__dirname, 'alizarin-napi.win32-ia32-msvc.node')
|
|
81
|
+
)
|
|
82
|
+
try {
|
|
83
|
+
if (localFileExisted) {
|
|
84
|
+
nativeBinding = require('./alizarin-napi.win32-ia32-msvc.node')
|
|
85
|
+
} else {
|
|
86
|
+
nativeBinding = require('@alizarin/napi-win32-ia32-msvc')
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
loadError = e
|
|
90
|
+
}
|
|
91
|
+
break
|
|
92
|
+
case 'arm64':
|
|
93
|
+
localFileExisted = existsSync(
|
|
94
|
+
join(__dirname, 'alizarin-napi.win32-arm64-msvc.node')
|
|
95
|
+
)
|
|
96
|
+
try {
|
|
97
|
+
if (localFileExisted) {
|
|
98
|
+
nativeBinding = require('./alizarin-napi.win32-arm64-msvc.node')
|
|
99
|
+
} else {
|
|
100
|
+
nativeBinding = require('@alizarin/napi-win32-arm64-msvc')
|
|
101
|
+
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
loadError = e
|
|
104
|
+
}
|
|
105
|
+
break
|
|
106
|
+
default:
|
|
107
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
+
}
|
|
109
|
+
break
|
|
110
|
+
case 'darwin':
|
|
111
|
+
localFileExisted = existsSync(join(__dirname, 'alizarin-napi.darwin-universal.node'))
|
|
112
|
+
try {
|
|
113
|
+
if (localFileExisted) {
|
|
114
|
+
nativeBinding = require('./alizarin-napi.darwin-universal.node')
|
|
115
|
+
} else {
|
|
116
|
+
nativeBinding = require('@alizarin/napi-darwin-universal')
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
} catch {}
|
|
120
|
+
switch (arch) {
|
|
121
|
+
case 'x64':
|
|
122
|
+
localFileExisted = existsSync(join(__dirname, 'alizarin-napi.darwin-x64.node'))
|
|
123
|
+
try {
|
|
124
|
+
if (localFileExisted) {
|
|
125
|
+
nativeBinding = require('./alizarin-napi.darwin-x64.node')
|
|
126
|
+
} else {
|
|
127
|
+
nativeBinding = require('@alizarin/napi-darwin-x64')
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadError = e
|
|
131
|
+
}
|
|
132
|
+
break
|
|
133
|
+
case 'arm64':
|
|
134
|
+
localFileExisted = existsSync(
|
|
135
|
+
join(__dirname, 'alizarin-napi.darwin-arm64.node')
|
|
136
|
+
)
|
|
137
|
+
try {
|
|
138
|
+
if (localFileExisted) {
|
|
139
|
+
nativeBinding = require('./alizarin-napi.darwin-arm64.node')
|
|
140
|
+
} else {
|
|
141
|
+
nativeBinding = require('@alizarin/napi-darwin-arm64')
|
|
142
|
+
}
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadError = e
|
|
145
|
+
}
|
|
146
|
+
break
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
149
|
+
}
|
|
150
|
+
break
|
|
151
|
+
case 'freebsd':
|
|
152
|
+
if (arch !== 'x64') {
|
|
153
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
154
|
+
}
|
|
155
|
+
localFileExisted = existsSync(join(__dirname, 'alizarin-napi.freebsd-x64.node'))
|
|
156
|
+
try {
|
|
157
|
+
if (localFileExisted) {
|
|
158
|
+
nativeBinding = require('./alizarin-napi.freebsd-x64.node')
|
|
159
|
+
} else {
|
|
160
|
+
nativeBinding = require('@alizarin/napi-freebsd-x64')
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
loadError = e
|
|
164
|
+
}
|
|
165
|
+
break
|
|
166
|
+
case 'linux':
|
|
167
|
+
switch (arch) {
|
|
168
|
+
case 'x64':
|
|
169
|
+
if (isMusl()) {
|
|
170
|
+
localFileExisted = existsSync(
|
|
171
|
+
join(__dirname, 'alizarin-napi.linux-x64-musl.node')
|
|
172
|
+
)
|
|
173
|
+
try {
|
|
174
|
+
if (localFileExisted) {
|
|
175
|
+
nativeBinding = require('./alizarin-napi.linux-x64-musl.node')
|
|
176
|
+
} else {
|
|
177
|
+
nativeBinding = require('@alizarin/napi-linux-x64-musl')
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadError = e
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
localFileExisted = existsSync(
|
|
184
|
+
join(__dirname, 'alizarin-napi.linux-x64-gnu.node')
|
|
185
|
+
)
|
|
186
|
+
try {
|
|
187
|
+
if (localFileExisted) {
|
|
188
|
+
nativeBinding = require('./alizarin-napi.linux-x64-gnu.node')
|
|
189
|
+
} else {
|
|
190
|
+
nativeBinding = require('@alizarin/napi-linux-x64-gnu')
|
|
191
|
+
}
|
|
192
|
+
} catch (e) {
|
|
193
|
+
loadError = e
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break
|
|
197
|
+
case 'arm64':
|
|
198
|
+
if (isMusl()) {
|
|
199
|
+
localFileExisted = existsSync(
|
|
200
|
+
join(__dirname, 'alizarin-napi.linux-arm64-musl.node')
|
|
201
|
+
)
|
|
202
|
+
try {
|
|
203
|
+
if (localFileExisted) {
|
|
204
|
+
nativeBinding = require('./alizarin-napi.linux-arm64-musl.node')
|
|
205
|
+
} else {
|
|
206
|
+
nativeBinding = require('@alizarin/napi-linux-arm64-musl')
|
|
207
|
+
}
|
|
208
|
+
} catch (e) {
|
|
209
|
+
loadError = e
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
localFileExisted = existsSync(
|
|
213
|
+
join(__dirname, 'alizarin-napi.linux-arm64-gnu.node')
|
|
214
|
+
)
|
|
215
|
+
try {
|
|
216
|
+
if (localFileExisted) {
|
|
217
|
+
nativeBinding = require('./alizarin-napi.linux-arm64-gnu.node')
|
|
218
|
+
} else {
|
|
219
|
+
nativeBinding = require('@alizarin/napi-linux-arm64-gnu')
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadError = e
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
break
|
|
226
|
+
case 'arm':
|
|
227
|
+
if (isMusl()) {
|
|
228
|
+
localFileExisted = existsSync(
|
|
229
|
+
join(__dirname, 'alizarin-napi.linux-arm-musleabihf.node')
|
|
230
|
+
)
|
|
231
|
+
try {
|
|
232
|
+
if (localFileExisted) {
|
|
233
|
+
nativeBinding = require('./alizarin-napi.linux-arm-musleabihf.node')
|
|
234
|
+
} else {
|
|
235
|
+
nativeBinding = require('@alizarin/napi-linux-arm-musleabihf')
|
|
236
|
+
}
|
|
237
|
+
} catch (e) {
|
|
238
|
+
loadError = e
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
localFileExisted = existsSync(
|
|
242
|
+
join(__dirname, 'alizarin-napi.linux-arm-gnueabihf.node')
|
|
243
|
+
)
|
|
244
|
+
try {
|
|
245
|
+
if (localFileExisted) {
|
|
246
|
+
nativeBinding = require('./alizarin-napi.linux-arm-gnueabihf.node')
|
|
247
|
+
} else {
|
|
248
|
+
nativeBinding = require('@alizarin/napi-linux-arm-gnueabihf')
|
|
249
|
+
}
|
|
250
|
+
} catch (e) {
|
|
251
|
+
loadError = e
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break
|
|
255
|
+
case 'riscv64':
|
|
256
|
+
if (isMusl()) {
|
|
257
|
+
localFileExisted = existsSync(
|
|
258
|
+
join(__dirname, 'alizarin-napi.linux-riscv64-musl.node')
|
|
259
|
+
)
|
|
260
|
+
try {
|
|
261
|
+
if (localFileExisted) {
|
|
262
|
+
nativeBinding = require('./alizarin-napi.linux-riscv64-musl.node')
|
|
263
|
+
} else {
|
|
264
|
+
nativeBinding = require('@alizarin/napi-linux-riscv64-musl')
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
loadError = e
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
localFileExisted = existsSync(
|
|
271
|
+
join(__dirname, 'alizarin-napi.linux-riscv64-gnu.node')
|
|
272
|
+
)
|
|
273
|
+
try {
|
|
274
|
+
if (localFileExisted) {
|
|
275
|
+
nativeBinding = require('./alizarin-napi.linux-riscv64-gnu.node')
|
|
276
|
+
} else {
|
|
277
|
+
nativeBinding = require('@alizarin/napi-linux-riscv64-gnu')
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadError = e
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
break
|
|
284
|
+
case 's390x':
|
|
285
|
+
localFileExisted = existsSync(
|
|
286
|
+
join(__dirname, 'alizarin-napi.linux-s390x-gnu.node')
|
|
287
|
+
)
|
|
288
|
+
try {
|
|
289
|
+
if (localFileExisted) {
|
|
290
|
+
nativeBinding = require('./alizarin-napi.linux-s390x-gnu.node')
|
|
291
|
+
} else {
|
|
292
|
+
nativeBinding = require('@alizarin/napi-linux-s390x-gnu')
|
|
293
|
+
}
|
|
294
|
+
} catch (e) {
|
|
295
|
+
loadError = e
|
|
296
|
+
}
|
|
297
|
+
break
|
|
298
|
+
default:
|
|
299
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
300
|
+
}
|
|
301
|
+
break
|
|
302
|
+
default:
|
|
303
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!nativeBinding) {
|
|
307
|
+
if (loadError) {
|
|
308
|
+
throw loadError
|
|
309
|
+
}
|
|
310
|
+
throw new Error(`Failed to load native binding`)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const { NapiRdmCache, NapiNodeConfigManager, NapiPseudoValue, NapiPseudoList, NapiPopulateResult, NapiEnsureNodegroupResult, NapiValuesFromNodegroupResult, NapiResourceInstanceWrapper, NapiResourceModelWrapper, NapiPrebuildLoader, NapiPrebuildExporter, NapiStaticGraph, NapiStaticResourceRegistry, buildGraphFromCsvs, buildBusinessDataFromCsv, extensionCoerce, extensionRenderDisplay, extensionResolveMarkers, hasExtensionHandler, getRegisteredExtensionHandlers } = nativeBinding
|
|
314
|
+
|
|
315
|
+
module.exports.NapiRdmCache = NapiRdmCache
|
|
316
|
+
module.exports.NapiNodeConfigManager = NapiNodeConfigManager
|
|
317
|
+
module.exports.NapiPseudoValue = NapiPseudoValue
|
|
318
|
+
module.exports.NapiPseudoList = NapiPseudoList
|
|
319
|
+
module.exports.NapiPopulateResult = NapiPopulateResult
|
|
320
|
+
module.exports.NapiEnsureNodegroupResult = NapiEnsureNodegroupResult
|
|
321
|
+
module.exports.NapiValuesFromNodegroupResult = NapiValuesFromNodegroupResult
|
|
322
|
+
module.exports.NapiResourceInstanceWrapper = NapiResourceInstanceWrapper
|
|
323
|
+
module.exports.NapiResourceModelWrapper = NapiResourceModelWrapper
|
|
324
|
+
module.exports.NapiPrebuildLoader = NapiPrebuildLoader
|
|
325
|
+
module.exports.NapiPrebuildExporter = NapiPrebuildExporter
|
|
326
|
+
module.exports.NapiStaticGraph = NapiStaticGraph
|
|
327
|
+
module.exports.NapiStaticResourceRegistry = NapiStaticResourceRegistry
|
|
328
|
+
module.exports.buildGraphFromCsvs = buildGraphFromCsvs
|
|
329
|
+
module.exports.buildBusinessDataFromCsv = buildBusinessDataFromCsv
|
|
330
|
+
module.exports.extensionCoerce = extensionCoerce
|
|
331
|
+
module.exports.extensionRenderDisplay = extensionRenderDisplay
|
|
332
|
+
module.exports.extensionResolveMarkers = extensionResolveMarkers
|
|
333
|
+
module.exports.hasExtensionHandler = hasExtensionHandler
|
|
334
|
+
module.exports.getRegisteredExtensionHandlers = getRegisteredExtensionHandlers
|