archiyou 0.7.0

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.
Files changed (83) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +215 -0
  3. package/dist/archiyou.js +35969 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/src/Annotator.d.ts +55 -0
  6. package/dist/src/AnnotatorBaseAnnotation.d.ts +16 -0
  7. package/dist/src/AnnotatorDimensionLine.d.ts +92 -0
  8. package/dist/src/Bbox.d.ts +126 -0
  9. package/dist/src/Beams.d.ts +316 -0
  10. package/dist/src/Brep.d.ts +152 -0
  11. package/dist/src/Calc.d.ts +48 -0
  12. package/dist/src/CalcDb.d.ts +33 -0
  13. package/dist/src/CalcTable.d.ts +60 -0
  14. package/dist/src/CalcTableIO.d.ts +130 -0
  15. package/dist/src/CodeParser.d.ts +58 -0
  16. package/dist/src/ComponentManager.d.ts +33 -0
  17. package/dist/src/Console.d.ts +34 -0
  18. package/dist/src/Doc.d.ts +181 -0
  19. package/dist/src/DocDocument.d.ts +27 -0
  20. package/dist/src/DocPDFExporter.d.ts +105 -0
  21. package/dist/src/DocPage.d.ts +75 -0
  22. package/dist/src/DocPageContainer.d.ts +65 -0
  23. package/dist/src/DocPageContainerGraphic.d.ts +10 -0
  24. package/dist/src/DocPageContainerImage.d.ts +21 -0
  25. package/dist/src/DocPageContainerTable.d.ts +21 -0
  26. package/dist/src/DocPageContainerText.d.ts +23 -0
  27. package/dist/src/DocPageContainerTextArea.d.ts +23 -0
  28. package/dist/src/DocPageContainerView.d.ts +22 -0
  29. package/dist/src/DocUtils.d.ts +12 -0
  30. package/dist/src/DocViewSVGManager.d.ts +91 -0
  31. package/dist/src/Edge.d.ts +190 -0
  32. package/dist/src/Exporter.d.ts +100 -0
  33. package/dist/src/Face.d.ts +134 -0
  34. package/dist/src/GLTFBuilder.d.ts +30 -0
  35. package/dist/src/IO.d.ts +87 -0
  36. package/dist/src/LibraryConnector.d.ts +56 -0
  37. package/dist/src/Make.d.ts +85 -0
  38. package/dist/src/MakeOperations.d.ts +32 -0
  39. package/dist/src/OBbox.d.ts +121 -0
  40. package/dist/src/Obj.d.ts +104 -0
  41. package/dist/src/OcLoader.d.ts +39 -0
  42. package/dist/src/ParamManager.d.ts +57 -0
  43. package/dist/src/ParamManagerOperator.d.ts +68 -0
  44. package/dist/src/Pipeline.d.ts +20 -0
  45. package/dist/src/Point.d.ts +88 -0
  46. package/dist/src/Runner.d.ts +230 -0
  47. package/dist/src/RunnerComponentImporter.d.ts +71 -0
  48. package/dist/src/RunnerOps.d.ts +15 -0
  49. package/dist/src/Script.d.ts +78 -0
  50. package/dist/src/ScriptOutputManager.d.ts +19 -0
  51. package/dist/src/ScriptOutputPath.d.ts +48 -0
  52. package/dist/src/ScriptParam.d.ts +78 -0
  53. package/dist/src/Selector.d.ts +48 -0
  54. package/dist/src/Services.d.ts +68 -0
  55. package/dist/src/Shape.d.ts +628 -0
  56. package/dist/src/ShapeCollection.d.ts +429 -0
  57. package/dist/src/Shell.d.ts +48 -0
  58. package/dist/src/Sketch.d.ts +162 -0
  59. package/dist/src/Solid.d.ts +54 -0
  60. package/dist/src/Vector.d.ts +167 -0
  61. package/dist/src/Vertex.d.ts +57 -0
  62. package/dist/src/VertexCollection.d.ts +11 -0
  63. package/dist/src/Wire.d.ts +180 -0
  64. package/dist/src/constants.d.ts +112 -0
  65. package/dist/src/decorators.d.ts +27 -0
  66. package/dist/src/garbageCollection.d.ts +4 -0
  67. package/dist/src/init.d.ts +5 -0
  68. package/dist/src/internal.d.ts +67 -0
  69. package/dist/src/models.d.ts +40 -0
  70. package/dist/src/typeguards.d.ts +88 -0
  71. package/dist/src/types.d.ts +944 -0
  72. package/dist/src/utils.d.ts +140 -0
  73. package/dist/src/wasm/build-scripts/build_wasm_base64.d.ts +8 -0
  74. package/dist/src/wasm/index.d.ts +8 -0
  75. package/dist/src/workerUtils.d.ts +14 -0
  76. package/dist/wasm/README.md +13 -0
  77. package/dist/wasm/archiyou-opencascade.d.ts +9933 -0
  78. package/dist/wasm/archiyou-opencascade.js +16 -0
  79. package/dist/wasm/archiyou-opencascade.wasm +0 -0
  80. package/dist/wasm/index.js +32 -0
  81. package/dist/wasm/node.d.ts +16 -0
  82. package/dist/wasm/node.js +40 -0
  83. package/package.json +66 -0
@@ -0,0 +1,230 @@
1
+ import { ArchiyouApp, Statement, StatementResult, RunnerScriptScopeState, ScriptOutputFormat, ScriptOutputData, RunnerScriptExecutionResult, Script, Pipeline, RunnerRole, RunnerScriptExecutionRequest, RunnerActiveScope, RunnerWorkerMessage, RunnerManagerMessage, ScriptParamData } from './internal';
2
+ export declare class Runner {
3
+ ay: ArchiyouApp;
4
+ role: RunnerRole;
5
+ _config: Record<string, any>;
6
+ _oc: any;
7
+ _localScopes: Record<string, any>;
8
+ _activeScope: RunnerActiveScope;
9
+ _activeExecRequest: RunnerScriptExecutionRequest;
10
+ _componentScripts: Record<string, Script>;
11
+ _pipelines: Array<Pipeline>;
12
+ _pipelineExports: Array<any>;
13
+ _manageWorker: Worker | null;
14
+ _onWorkerMessageFunc: (m: RunnerWorkerMessage) => any;
15
+ LOGGING_DEBUG: boolean;
16
+ DEFAULT_ROLE: RunnerRole;
17
+ DEFAULT_OUTPUTS: string[];
18
+ OUTPUT_FORMAT_DEFAULTS: Record<ScriptOutputFormat, Record<string, any>>;
19
+ /**
20
+ * Create a new Runner instance on main thread (as manager or single)
21
+ * Or as parallel worker (Webworker or WorkerThread) listening to incoming messages before doing the work
22
+ */
23
+ constructor(role?: RunnerRole);
24
+ /** Loading Archiyou library with WASM module
25
+ @returns [Runner, OC library]
26
+ */
27
+ load(): Promise<this>;
28
+ /** If OpenCascade is loaded */
29
+ loaded(): boolean;
30
+ startAsManager(worker?: Worker, settings?: Record<string, any>): this;
31
+ /** Supply a function to call when we get a message from the Worker */
32
+ onWorkerMessage(func: (message: RunnerWorkerMessage) => any): this;
33
+ /** Send message to Worker
34
+ * IMPORTANT: data can only contain standard data types (no functions, classes etc)
35
+ */
36
+ _postMessageToWorker(message: RunnerManagerMessage): void;
37
+ /** Setup communication between manager and worker */
38
+ _connectToWorker(settings?: Record<string, any>): void;
39
+ _handleMessageFromWorker(m: MessageEvent): void;
40
+ /** Set current runner as worker wihtin a parallel thread
41
+ * Listen to messages on ports, execute scripts and send back the results
42
+ */
43
+ _startAsWorker(): this;
44
+ _startWorkerListener(): any;
45
+ /** Post message as worker to parent
46
+ * IMPORTANT: data can only contain standard data types (no functions, classes etc)
47
+ */
48
+ _postMessageToManager(message: RunnerWorkerMessage): void;
49
+ _handleMessageFromManager(e: MessageEvent): Promise<void>;
50
+ _getWorkerContext(): globalThis | null;
51
+ _getWorkerThreadContext(): null;
52
+ _getWorkerContextName(): 'webworker' | 'workerthread';
53
+ /** Set Execution Scope
54
+ * Depending on the execution context we set up a scope in which the script will run
55
+ *
56
+ * NOTES:
57
+ * - big errors like 'var Module=typeof Module!="undefined"?Module:{}....' are ofter thrown when any problem arrises
58
+ *
59
+ * */
60
+ createScope(name?: string): this;
61
+ /** Build start Archiyou state for a execution scope
62
+ * Each scope uses its own instances of Archiyou modules
63
+ */
64
+ buildLocalExecScopeState(): RunnerScriptScopeState;
65
+ /** Initiate all Archiyou modules and return a state object
66
+ * that is plugged into a local execution scope
67
+ */
68
+ initLocalArchiyou(): ArchiyouApp;
69
+ /** Our scopes are very limited. We need to make sure basic globals are availble */
70
+ _addGlobalsToScopeState(state: Record<string, any>): Record<string, any>;
71
+ /** Add Archiyou modules as globals in execution scope state object */
72
+ _addModulesToScopeState(state: Record<string, any>): Record<string, any>;
73
+ _addLoggingToScopeState(state: Record<string, any>): Record<string, any>;
74
+ /** Make general modeling methods available in scope state object */
75
+ _addModelingMethodsToScopeState(state: Record<string, any>): Record<string, any>;
76
+ /** Add specific meta methods */
77
+ _addMetaMethodsToScopeState(state: Record<string, any>): void;
78
+ /** Make a new pipeline. Use .do(fn) to set function later */
79
+ pipeline(name?: string, fn?: () => any): Pipeline;
80
+ getPipelineNames(): Array<string>;
81
+ getPipelineByName(name: string): Pipeline;
82
+ /** Select a scope */
83
+ scope(name: string): this;
84
+ getLocalActiveScope(): RunnerScriptScopeState;
85
+ getLocalScope(name: string): RunnerScriptScopeState;
86
+ deleteLocalScope(name: string): this;
87
+ /** Start execution of entire code or script with params in fresh, active scope
88
+ * @request - string with code or object with script and params
89
+ * @result - return the result of the execution
90
+ */
91
+ execute(request: string | RunnerScriptExecutionRequest): Promise<RunnerScriptExecutionResult>;
92
+ /** Execute (entire or partial) request on local execution scope or on managed worker */
93
+ private _execute;
94
+ /** Main entrypoint for execution in statements
95
+ * Use this is you need more control of execution and possible errors
96
+ * This seperates the code in statements and returns results for each statement
97
+ * It still uses execute() internally
98
+ */
99
+ executeInStatements(request: RunnerScriptExecutionRequest): Promise<RunnerScriptExecutionResult>;
100
+ /** Check execution request */
101
+ _checkRequestAndAddDefaults(request: RunnerScriptExecutionRequest): RunnerScriptExecutionRequest;
102
+ /** Check params in RunnerScriptExecutionRequest
103
+ * We need to make sure that param values are there and consistent with param definitions
104
+ * - if param values (request.params) are not set, we use default values from script.params definitions
105
+ * - param values (request.params) are put in defs (request.script.params)
106
+ *
107
+ * TODO: Use ScriptParam.validateValue() to validate incoming values
108
+ *
109
+ * */
110
+ _checkRequestParams(request: RunnerScriptExecutionRequest): RunnerScriptExecutionRequest;
111
+ /** Execute a request in a seperate managed worker */
112
+ _executeInWorker(request: RunnerScriptExecutionRequest): Promise<RunnerScriptExecutionResult>;
113
+ /** Execute a piece of code or script (and params) in local execution context
114
+ * @param {RunnerScriptExecutionRequest} [request] - string with code or object with script and params
115
+ * @param {boolean} [startRun] - if true a reset is made of the state to prepare for fresh run
116
+ * @param {boolean} [output] - if true, the Archiyou state is returned as RunnerScriptExecutionResult
117
+ *
118
+ * @returns - RunnerScriptExecutionResult or error string or null if no output
119
+ *
120
+ * NOTE: this = execution context (not Runner)
121
+ */
122
+ _executeLocal(request: RunnerScriptExecutionRequest, startRun?: boolean, output?: boolean): Promise<RunnerScriptExecutionResult | null>;
123
+ _handleExecutionError(scope: RunnerScriptScopeState, request: RunnerScriptExecutionRequest, code: string, e: Error): RunnerScriptExecutionResult;
124
+ _extractScriptContextFromErrorStack(e: Error, code: string): string | null;
125
+ /** Run a execution request (with script, params etc) in individual statements
126
+ * This is used for debugging and testing in browser
127
+ * NOTE: see executeInStatements() for main entrypoint
128
+ */
129
+ _executeLocalInStatements(request: RunnerScriptExecutionRequest, statementResults: Array<StatementResult>): Promise<RunnerScriptExecutionResult>;
130
+ /** Some preprocessing for statements */
131
+ _preprocessStatement(statement: Statement): Statement;
132
+ /** Setup for every execution run inside execution scope
133
+ * IMPORTANT: 'this' is the execution scope
134
+ */
135
+ _executionStartRunInScope(scope: any, request: RunnerScriptExecutionRequest): void;
136
+ /** Execute a component script in a seperate scope
137
+ * This is always done in local context
138
+ * because executing components comes from within execution scope and context
139
+ * IMPORTANT:
140
+ * - We want to avoid writing in a script: await $component('name').get(..)
141
+ * which will be ugly and prone to errors
142
+ * - So a sync function is used to execute component scripts
143
+ * - This also means that we need to pre-fetch all component scripts before executing them
144
+ */
145
+ _executeComponentScript(request: RunnerScriptExecutionRequest): RunnerScriptExecutionResult;
146
+ /** For executing component scripts we need to have synchronous execution function
147
+ * Because we don't want to write await $component('name').get() in the code
148
+ * This is possible only if we use sync methods in the code
149
+ * In this case that's no problem because we need the existing internal instances
150
+ * from Component scope for model, metrics, docs, tables
151
+ *
152
+ * NOTE: This is run in the local scope, so 'this' is the execution scope
153
+ */
154
+ _executeLocalComponent(request: RunnerScriptExecutionRequest, startRun?: boolean, output?: boolean): RunnerScriptExecutionResult | null;
155
+ _prefetchComponentScripts(request: string | RunnerScriptExecutionRequest, noCache?: boolean): Promise<Record<string, Script>>;
156
+ /** Fetch component script from url or local file path */
157
+ _fetchComponentScript(path?: string): Promise<Script | null>;
158
+ /** Get component from cache in componentScripts
159
+ * Cache needs to be filled by this._prefetchComponentScripts()
160
+ */
161
+ getComponentScript(name: string): Script | null;
162
+ executePipeline(pipeline: Pipeline, request: RunnerScriptExecutionRequest): Promise<RunnerScriptExecutionResult | null>;
163
+ /** Execute a Pipeline in a isolated scope and extract requested outputs
164
+ * NOTE: Based on _executeLocal() but simplified for ease of use
165
+ */
166
+ private _executePipelineIsolated;
167
+ /** Execute from URL of Archiyou library */
168
+ executeUrl(url: string, params?: Record<string, ScriptParamData>, outputs?: Array<string>): Promise<RunnerScriptExecutionResult>;
169
+ getDefaultComponentLibraryUrl(): string;
170
+ getServicesUrl(): string;
171
+ /** Get a script directly from URL
172
+ * We need to parse the url to get the library address and that of the script */
173
+ getScriptFromUrl(url: string): Promise<Script>;
174
+ _getLibUrlFromScriptUrl(url: string): string | null;
175
+ _getScriptPathFromScriptUrl(url: string): string | null;
176
+ _addMetaToResult(scope: RunnerScriptScopeState, request: RunnerScriptExecutionRequest, result: RunnerScriptExecutionResult): RunnerScriptExecutionResult;
177
+ /** Get results out of local execution scope
178
+ * This function is bound to the scope - so 'this' is the execution scope
179
+ * If this method is run only if there were no errors during execution
180
+ */
181
+ getLocalScopeResults(scope: RunnerScriptScopeState, request: RunnerScriptExecutionRequest): Promise<RunnerScriptExecutionResult>;
182
+ /** Get results from local execution scope based on
183
+ * request.outputs paths
184
+ * We gather result by pipeline, because we can have multiple pipelines in the request that need to be run
185
+ *
186
+ * @scope - execution scope to get results from
187
+ * @request - execution request with outputs
188
+ *
189
+ * @returns - Array of ScriptOutputData with path and output data { path: ScriptOutputPath, output: any }
190
+ *
191
+ * NOTE: There is a recursive aspect here, because in the default pipeline (main scope) we run pipelines first
192
+ * in a seperate scope and get its results. Here this function is used too.
193
+ */
194
+ getLocalScopeResultOutputs(scope: RunnerScriptScopeState, request: RunnerScriptExecutionRequest, result: RunnerScriptExecutionResult): Promise<Array<ScriptOutputData>>;
195
+ /**
196
+ * Get results out of local execution scope synchronously for Components
197
+ * For special cases like importing components we want to avoid async methods */
198
+ getLocalScopeResultsComponent(scope: any, request: RunnerScriptExecutionRequest): RunnerScriptExecutionResult;
199
+ /** Export models from given scope, pipeline and using output paths in request.outputs and place in ExecutionResult tree */
200
+ _exportPipelineModels(scope: any, request: RunnerScriptExecutionRequest, pipeline: string, result: RunnerScriptExecutionResult): Promise<Array<ScriptOutputData>>;
201
+ _exportPipelineMetrics(scope: any, request: RunnerScriptExecutionRequest, pipeline: string, result: RunnerScriptExecutionResult): Promise<Array<ScriptOutputData>>;
202
+ _exportPipelineTables(scope: any, request: RunnerScriptExecutionRequest, pipeline: string, result: RunnerScriptExecutionResult): Promise<Array<ScriptOutputData>>;
203
+ _exportPipelineDocs(scope: any, request: RunnerScriptExecutionRequest, pipeline: string, result: RunnerScriptExecutionResult): Promise<Array<ScriptOutputData>>;
204
+ /** Get internal outputs synchronously per pipeline
205
+ * Iterate from outputs and run pipelines where needed
206
+ */
207
+ getLocalScopeResultOutputsInternal(scope: any, request: RunnerScriptExecutionRequest, result: RunnerScriptExecutionResult): Array<ScriptOutputData>;
208
+ /** Get internal Obj/Shape model data from local execution scope */
209
+ _exportPipelineModelsInternal(scope: any, request: RunnerScriptExecutionRequest, pipeline: string, result: RunnerScriptExecutionResult): Array<ScriptOutputData>;
210
+ /** Get internal Metric data from local execution scope and set in result tree */
211
+ _exportPipelineMetricsInternal(scope: any, request: RunnerScriptExecutionRequest, pipeline: string, result: RunnerScriptExecutionResult): Array<ScriptOutputData>;
212
+ /** Get internal Table data from local execution scope and set in result tree */
213
+ _exportPipelineTablesInternal(scope: any, request: RunnerScriptExecutionRequest, pipeline: string, result: RunnerScriptExecutionResult): Array<ScriptOutputData>;
214
+ /** Get internal Doc data from local execution scope and set in result tree
215
+ * Because of the Doc module is tied to the execution scope, we export raw data here (Doc.toData())
216
+ */
217
+ _exportPipelineDocsInternal(scope: any, request: RunnerScriptExecutionRequest, pipeline: string, result: RunnerScriptExecutionResult): Array<ScriptOutputData>;
218
+ inNode(): boolean;
219
+ /**
220
+ * Convert a string value to its native type if possible.
221
+ * - "true"/"false" (case-insensitive) => boolean
222
+ * - Numeric strings => number
223
+ * - Otherwise, return as string
224
+ */
225
+ _convertStringValue(value: string): string | number | boolean;
226
+ /**
227
+ * Returns the longest substring that is both a suffix of str1 and a prefix of str2.
228
+ */
229
+ _stringOverlap(str1: string, str2: string): string;
230
+ }
@@ -0,0 +1,71 @@
1
+ import { Runner, Script, RunnerScriptScopeState, Obj, PublishScript, ImportComponentResult } from './internal';
2
+ /**
3
+ * Exists in script execution scope
4
+ * And gathers all information needed to execute a component script
5
+ * and return specific results
6
+ *
7
+ * Executing component script and getting result (async/sync)
8
+ * Script execution is async, but we want to avoid using
9
+ * "await $component(...).get(...)" which is not user friendly
10
+ *
11
+ * Because all the export functions for raw data (the model Obj/Shapes, table data and doc instances)
12
+ * that is by definition always available in the scope
13
+ * We can get away with introducing a sync execution method
14
+ * RunnerComponentImporter.get() => Runner._executeComponentScript => Runner._executeLocalSync
15
+ *
16
+ * Some usage examples based on get and shortcuts methods model() and all():
17
+ *
18
+ * - leftWall = $component("test/wall", { LENGTH: 300, HEIGHT: 250 }).model() // default pipeline model Obj
19
+ * ==> same as: $component("test/wall", { LENGTH: 300, HEIGHT: 250 }).get('default/model')
20
+ * - cutShapes = $component("test/box", { WIDTH: 100, DEPTH: 100 }).get('cnc/model')
21
+ * - { model: wallShape, docs: wallDocs, tables: wallTables } = $component("test/wall", { }).all()
22
+ * ==> same as: $component("test/wall", { }).get('default/model','default/tables', 'default/docs', 'default/metrics')
23
+ *
24
+ *
25
+ */
26
+ export declare class RunnerComponentImporter {
27
+ DEFAULT_OUTPUTS: string[];
28
+ _runner: Runner;
29
+ _scope: RunnerScriptScopeState;
30
+ name: string;
31
+ params: Record<string, any>;
32
+ options: Record<string, any>;
33
+ script?: PublishScript;
34
+ _requestedOutputs: Array<string>;
35
+ constructor(runner: Runner, scope: RunnerScriptScopeState, name: string, params?: Record<string, any>);
36
+ /**
37
+ * Get outputs from component script execution
38
+ * This will enable the user to get specific outputs from the component:
39
+ * - any pipeline
40
+ * - any category: model, docss, tables, metrics
41
+ *
42
+ * @param p - path or array of paths to requested outputs (like 'default/model', 'cnc/model')
43
+ *
44
+ * Components only work with internal data, so we always get 'internal' format
45
+ * Some simplications:
46
+ * - no other formats than 'internal'
47
+ * - we export internal categories like 'model', 'docs', 'tables', 'metrics' directly as module instances
48
+ * : no specific entities like 'docs/report'
49
+ * - if only one output path given (for example 'default/model') return that directly
50
+ *
51
+ * See RunnerComponentImporter.model() for easy way of getting model
52
+ *
53
+ * */
54
+ get(p: string | Array<string>): ImportComponentResult;
55
+ /** Shortcut method for getting model */
56
+ model(): ImportComponentResult;
57
+ /** Shortcut method for getting everything of default pipeline */
58
+ all(): ImportComponentResult;
59
+ /** Really get the script and execute in seperate component scope */
60
+ _getAndExecute(): ImportComponentResult;
61
+ /** Execute component script with params and requested outputs
62
+ * @param script - PublishScript to execute
63
+ * @param params - parameters to pass to the script
64
+ * @returns Promise<ImportComponentResult> - result of the execution
65
+ */
66
+ _executeComponentScript(script: Script): ImportComponentResult;
67
+ /** Get component script from Runners cache (in Runner.componentScripts) */
68
+ _getComponentScript(): Script | null;
69
+ /** We need to recreate the component object tree into the current scope */
70
+ _recreateComponentObjTree(tree: Object, parentObj?: Obj): Obj;
71
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * RunnerOps.ts
3
+ * Class for some common operations
4
+ *
5
+ */
6
+ export declare class RunnerOps {
7
+ constructor();
8
+ /**
9
+ * Saves a Blob, ArrayBuffer, Uint8Array, or string to the local file system.
10
+ * @param data - The data to save (Blob, ArrayBuffer, Uint8Array, or string).
11
+ * @param filePath - The path where the file should be saved.
12
+ * @param overwrite - Whether to overwrite existing files (default: true).
13
+ */
14
+ saveBlobToFile(data: Blob | ArrayBuffer | Uint8Array | string, filePath: string, overwrite?: boolean): Promise<void>;
15
+ }
@@ -0,0 +1,78 @@
1
+ import { ScriptParamData, ScriptPublished, ScriptMeta, ScriptParam } from './internal';
2
+ export declare class Script {
3
+ id: string;
4
+ name: undefined | string;
5
+ author: undefined | string;
6
+ description: undefined | string;
7
+ tags: string[];
8
+ created: Date;
9
+ updated: Date;
10
+ code: string;
11
+ params: Record<string, ScriptParam>;
12
+ presets: Record<string, Record<string, ScriptParamData>>;
13
+ meta: ScriptMeta | null;
14
+ published: ScriptPublished | null;
15
+ previousId?: string;
16
+ previousVersion?: string;
17
+ _valid: boolean;
18
+ constructor(author?: string, name?: string, code?: string, params?: Record<string, ScriptParam>, presets?: Record<string, Record<string, ScriptParamData>>);
19
+ isValid(): boolean;
20
+ namespace(): string;
21
+ validate(): void;
22
+ _setDefaults(): void;
23
+ _validateBasics(): boolean;
24
+ /** Validated ScriptPublished */
25
+ _validatePublished(): boolean;
26
+ /** Used by library to set public url of this script */
27
+ setPublishedUrl(rootUrl: string): this;
28
+ getDefaultParamValues(): Record<string, any>;
29
+ /** Check parameter values against script definition params and give back error messages
30
+ * @return
31
+ * success flag
32
+ * Record with valid values only
33
+ */
34
+ checkParamValuesVerbose(paramValues: Record<string, any>): {
35
+ success: boolean;
36
+ errors: Array<string>;
37
+ checkedParamValues: Record<string, any>;
38
+ };
39
+ /** Simple flag version */
40
+ checkParamValues(paramValues: Record<string, any>): boolean;
41
+ validateParamValues(paramValues: Record<string, any>): boolean;
42
+ /** When a script is executed with a set of params we generate a hash
43
+ * to uniquely identify the variant of the script. For example for caching
44
+ */
45
+ getVariantId(paramValues: Record<string, any>): Promise<string>;
46
+ /** Get number of possible variants */
47
+ getNumVariants(): number;
48
+ /** Iterate over all possible parameter variants
49
+ * @params params Array of parameter names to iterate over, others are kept to default
50
+ */
51
+ iterateVariants(only?: Array<string>): Generator<Record<string, any>>;
52
+ /** Generate all parameter combinations
53
+ * This function uses recursion to generate all possible combinations of parameter values.
54
+ */
55
+ _generateCombinations(params: Array<ScriptParam>, staticValues: Record<string, any>): Generator<Record<string, any>>;
56
+ /** Load from raw data
57
+ * Some backwards compatibility
58
+ */
59
+ fromData(data: Script | ScriptData | Record<string, any>): Script | this;
60
+ fixSemver(v: string): any;
61
+ /** To raw data */
62
+ toData(): ScriptData;
63
+ /** Export to module string - in this format the Script is saved in the library */
64
+ toModuleString(): string;
65
+ }
66
+ export interface ScriptData {
67
+ id: string;
68
+ name?: string;
69
+ author?: string;
70
+ description: string;
71
+ tags?: string[];
72
+ created: string | null;
73
+ updated: string | null;
74
+ code: string;
75
+ params: Record<string, ScriptParamData>;
76
+ presets?: Record<string, Record<string, ScriptParamData>>;
77
+ published: ScriptPublished | null;
78
+ }
@@ -0,0 +1,19 @@
1
+ import { ScriptOutputPath, ScriptOutputCategory, RunnerScriptExecutionRequest, RunnerScriptExecutionResult } from './internal';
2
+ export declare class ScriptOutputManager {
3
+ requestedOutputPaths: Array<ScriptOutputPath>;
4
+ resolvedOutputsPaths: Array<ScriptOutputPath>;
5
+ constructor();
6
+ /** Load incoming request that contains output request paths
7
+ * Any warnings will be places inside result.warnings
8
+ * @returns number of valid (resolved) output paths generated
9
+ */
10
+ loadRequest(request: RunnerScriptExecutionRequest, result?: RunnerScriptExecutionResult, resolve?: boolean): this;
11
+ /** If we want to manage outputs of a execution result without resolving paths
12
+ * This also ties outputs to the path objects for easy access
13
+ */
14
+ fromResult(result: RunnerScriptExecutionResult): this;
15
+ getPipelines(): Array<string>;
16
+ getOutputsByPipeline(pipeline: string): Array<ScriptOutputPath>;
17
+ getOutputsByPipelineCategory(pipeline: string, category: ScriptOutputCategory): Array<ScriptOutputPath>;
18
+ getOutputsByPipelineEntityFormats(pipeline: string, category: ScriptOutputCategory, formats: Array<string>): Array<ScriptOutputPath>;
19
+ }
@@ -0,0 +1,48 @@
1
+ import { ScriptMeta, ScriptOutputCategory, ScriptOutputFormat, ScriptOutputPathData, ScriptOutputDataWrapper } from './internal';
2
+ export declare class ScriptOutputPath {
3
+ requestedPath: string;
4
+ resolvedPath: string;
5
+ valid: boolean;
6
+ resolved: boolean;
7
+ pipeline: null | string;
8
+ category: null | '*' | ScriptOutputCategory;
9
+ entityName: null | '*' | string;
10
+ format: null | '*' | ScriptOutputFormat | null;
11
+ formatOptions: Record<string, any>;
12
+ _output: any | ScriptOutputDataWrapper;
13
+ constructor(outputPath?: string);
14
+ copy(): ScriptOutputPath;
15
+ toData(): ScriptOutputPathData;
16
+ fromData(data: ScriptOutputPathData): this;
17
+ /** Alter path for internal use in context of components
18
+ * We try to keep it the same as normal use */
19
+ internalize(): this;
20
+ setOutputData(data: any): this;
21
+ /** Load output path data from a cache file path */
22
+ fromCacheFilePath(filePath: string): this;
23
+ /** When saving output to cache we need a file path that contains all the info of the output */
24
+ toCacheFilePath(what?: 'full' | 'dir' | 'filename'): string | null;
25
+ private _validate;
26
+ checkValid(): boolean;
27
+ /** Resolve any wildcards in request output path by filling in the entity names
28
+ * @return one or multiple new Script Output instances
29
+ * and any warnings
30
+ * */
31
+ resolveVerbose(meta: ScriptMeta): {
32
+ resolved: Array<ScriptOutputPath>;
33
+ warnings: Array<string>;
34
+ };
35
+ /** Simple resolve of wildcards in current output path */
36
+ resolve(): Array<ScriptOutputPath>;
37
+ setResolved(): ScriptOutputPath;
38
+ hasWildCard(): boolean;
39
+ wildCardsAt(): Array<string>;
40
+ private _getEntitiesFromMeta;
41
+ /** Get all available formats by category
42
+ * set flag internal to true to also include 'internal' format
43
+ */
44
+ private _getFormatsByCategory;
45
+ private _metaHasEntityName;
46
+ /** Parse a URL parameter string into an object */
47
+ private _parseFormatOptions;
48
+ }
@@ -0,0 +1,78 @@
1
+ import { ModelUnits, ParamType, ParamObjectSchema, ParamBehaviourTarget } from './internal';
2
+ export declare class ScriptParam {
3
+ MAX_TEXT_LENGTH: number;
4
+ id: string;
5
+ type: ParamType;
6
+ name: string;
7
+ enabled?: boolean;
8
+ visible?: boolean;
9
+ label: string;
10
+ default?: any;
11
+ _value?: any | Array<any>;
12
+ min?: number;
13
+ max?: number;
14
+ step?: number;
15
+ options?: Array<string>;
16
+ length?: number;
17
+ listElem?: ScriptParam;
18
+ schema?: ParamObjectSchema;
19
+ order?: number;
20
+ iterable?: boolean;
21
+ description?: string;
22
+ units?: ModelUnits;
23
+ _definedProgrammatically?: boolean;
24
+ _behaviours?: Record<ParamBehaviourTarget, (curParam: ScriptParamData, params: Record<string, ScriptParam>) => any> | {};
25
+ constructor();
26
+ fromData(param: ScriptParamData): this;
27
+ /** Export ScriptParam instance to equivalent data structure */
28
+ toData(): ScriptParamData;
29
+ /** Validate incoming ScriptParamData object */
30
+ validateInput(param: ScriptParamData): ScriptParamData;
31
+ /** Make a easy class method */
32
+ static validate(param: ScriptParamData): ScriptParamData;
33
+ /** Validate structure of ParamData by type
34
+ * NOTE: _value is always internal, so we don't validate it here
35
+ * use validateParamValue() for value validation
36
+ */
37
+ validateStructure(param: ScriptParamData): boolean;
38
+ validateValue(v: any): boolean;
39
+ /** Validate any value against current Param instance */
40
+ validateValueVerbose(v: any): {
41
+ success: boolean;
42
+ errors: Array<string>;
43
+ };
44
+ /** If it makes sense to iterate over param values
45
+ * This means there are a limited set of values
46
+ */
47
+ isIterable(): boolean;
48
+ /** Get number of values that a Paramater can take
49
+ * If a Param is not iterable we directly return 1
50
+ */
51
+ numValues(): number;
52
+ /** Iterate over all param values */
53
+ iterateValues(): Generator<any>;
54
+ }
55
+ /** Data version of ScriptParam instance */
56
+ export interface ScriptParamData {
57
+ id?: string;
58
+ type: ParamType;
59
+ name: string;
60
+ enabled?: boolean;
61
+ visible?: boolean;
62
+ label: string;
63
+ _value?: any | Array<any>;
64
+ default?: any;
65
+ min?: number;
66
+ max?: number;
67
+ step?: number;
68
+ listElem?: ScriptParamData;
69
+ schema?: ParamObjectSchema;
70
+ options?: Array<string>;
71
+ length?: number;
72
+ units?: ModelUnits;
73
+ order?: number;
74
+ iterable?: boolean;
75
+ description?: string;
76
+ _definedProgrammatically?: boolean;
77
+ _behaviours?: Record<string, string>;
78
+ }
@@ -0,0 +1,48 @@
1
+ import { Selection, Shape, ShapeCollection } from './internal';
2
+ /**
3
+
4
+ Class for selecting parts of Shapes
5
+
6
+ ex:
7
+ Shape.select('E|Z') - Edges parallel to Z axis
8
+ Shape.select('V<<Z') - Vertex with smallest Z coordinate
9
+ Shape.select('V<X=10') - Vertex with X coordinate smaller than 10
10
+
11
+ subselect:
12
+
13
+ Shape.select('F||top).select('V||front')
14
+
15
+ add selections:
16
+
17
+ Shape.select('F||top and F||front')
18
+
19
+ How to add new selectors:
20
+
21
+ There is a configuration based scaffolding to easy parse the selectors.
22
+ Parsing selection strings is done in these phases:
23
+
24
+ 1. What are we looking for and how many: scan for target Shape (_setSelectionTargetShape)
25
+ ex: F == Faces = return all Faces, Face = return first Face -
26
+
27
+ 2. Which selector and parameters: _executeSelectString
28
+ _executeSelectString contains all parsing logic and is the place where you add new selectors.
29
+ !!!! IMPORTANT !!!! Parsing order of selector regular expressions is important:
30
+ Place the more complex ones first and simple ones (that might overlap with complex ones) later.
31
+
32
+ 3. Parsed selector and parameters are forwarded to specific selector method on Shape class as defined in _executeSelectString
33
+ that returns the real Shapes or ShapeCollection based on number of results a selector is suppose to return
34
+
35
+ */
36
+ export declare class Selector {
37
+ parentShape: Shape | ShapeCollection;
38
+ selectString: string;
39
+ lastSelection: Selection;
40
+ constructor(shape?: Shape);
41
+ /** Select Sub Shapes of a Shape by using a selection expression */
42
+ select(s: string): ShapeCollection;
43
+ /** We allow multiple selections with keyword 'and' */
44
+ _splitSelectStrings(selectString: string): Array<string>;
45
+ /** Scans string of selection for what we are looking for ~ the targetShape */
46
+ _setSelectionTargetShape(selection: Selection): Selection;
47
+ _executeSelectString(selectString: string): ShapeCollection;
48
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ *
3
+ * API Wrapper for Archiyou services
4
+ *
5
+ * - conversion between different data formats
6
+ * - TODO: more
7
+ */
8
+ /** API wrapper for Archiyou services */
9
+ export declare class Services {
10
+ private _baseUrl;
11
+ private _timeout;
12
+ private _headers;
13
+ private _nodeFormDataModule;
14
+ private _nodeFormFetchModule;
15
+ constructor(baseUrl: string, timeout?: number);
16
+ /** Set authentication token */
17
+ setAuthToken(token: string): this;
18
+ /** Set custom headers */
19
+ setHeaders(headers: Record<string, string>): this;
20
+ /** If Services instance is set with baseUrl */
21
+ ifSet(): boolean;
22
+ /** Check if the API service is up and running */
23
+ isUp(): Promise<boolean>;
24
+ getConversionFormats(): Promise<Array<ServiceConvertFormat>>;
25
+ /** Convert data from one format to another */
26
+ convert(data: ArrayBuffer | string, fromExt: string, toExt: string): Promise<ServiceConvertResponse>;
27
+ isNode(): boolean;
28
+ /** Upload binary data for conversion - works in both Node.js and browser */
29
+ private _uploadAndConvert;
30
+ private _loadNodeModules;
31
+ /** Node.js multipart upload */
32
+ private _uploadAndConvertNode;
33
+ /** Browser multipart upload */
34
+ private _uploadAndConvertBrowser;
35
+ /** Get available conversion formats */
36
+ getSupportedFormats(): Promise<{
37
+ input: string[];
38
+ output: string[];
39
+ }>;
40
+ /** Make HTTP request with error handling */
41
+ private _request;
42
+ }
43
+ export interface ServiceConvertFormat {
44
+ name: string;
45
+ ext: string;
46
+ description?: string;
47
+ importable: boolean;
48
+ exportable: boolean;
49
+ tool: 'assimp' | 'gdal';
50
+ }
51
+ export interface ServiceConvertRequest {
52
+ data: ArrayBuffer | string;
53
+ fromFormat: string;
54
+ toFormat: string;
55
+ }
56
+ export interface ServiceConvertResponse {
57
+ success: boolean;
58
+ data?: ArrayBuffer;
59
+ error?: string;
60
+ metadata?: {
61
+ originalSize: number;
62
+ convertedSize: number;
63
+ processingTime: number;
64
+ };
65
+ }
66
+ export interface ServiceHealthResponse {
67
+ message: string;
68
+ }