@dxos/compute 0.8.4-main.f9ba587 → 0.8.4-main.fcfe5033a5
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/lib/{browser/chunk-2PBHA7EI.mjs → neutral/chunk-JRV42MW3.mjs} +109 -86
- package/dist/lib/neutral/chunk-JRV42MW3.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/index.mjs +1 -1
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/testing/index.mjs +52 -6
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/compute-graph-registry.d.ts +10 -7
- package/dist/types/src/compute-graph-registry.d.ts.map +1 -1
- package/dist/types/src/compute-graph-registry.test.d.ts +2 -0
- package/dist/types/src/compute-graph-registry.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph.d.ts +10 -7
- package/dist/types/src/compute-graph.d.ts.map +1 -1
- package/dist/types/src/compute-node.d.ts +1 -2
- package/dist/types/src/compute-node.d.ts.map +1 -1
- package/dist/types/src/functions/async-function.d.ts +13 -11
- package/dist/types/src/functions/async-function.d.ts.map +1 -1
- package/dist/types/src/functions/edge-function.d.ts +3 -3
- package/dist/types/src/functions/edge-function.d.ts.map +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +1 -1
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-plugin.d.ts +4 -5
- package/dist/types/src/testing/test-plugin.d.ts.map +1 -1
- package/dist/types/src/testing/test-runtime.d.ts +10 -0
- package/dist/types/src/testing/test-runtime.d.ts.map +1 -0
- package/dist/types/src/types/hyperformula.d.ts +3 -6
- package/dist/types/src/types/hyperformula.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +31 -33
- package/src/compute-graph-registry.test.ts +167 -0
- package/src/compute-graph-registry.ts +20 -13
- package/src/compute-graph.test.ts +63 -12
- package/src/compute-graph.ts +43 -37
- package/src/compute-node.ts +2 -4
- package/src/functions/async-function.ts +21 -16
- package/src/functions/edge-function.ts +28 -31
- package/src/hyperformula.test.ts +2 -2
- package/src/index.ts +0 -27
- package/src/testing/index.ts +1 -0
- package/src/testing/test-builder.ts +7 -2
- package/src/testing/test-plugin.ts +2 -4
- package/src/testing/test-runtime.ts +53 -0
- package/src/testing/util.ts +1 -1
- package/src/types/hyperformula.ts +8 -8
- package/src/types/types.test.ts +2 -2
- package/dist/lib/browser/chunk-2PBHA7EI.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GTPQNWA3.mjs +0 -3080
- package/dist/lib/node-esm/chunk-GTPQNWA3.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -56
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -174
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/vendor/hyperformula.mjs +0 -36400
- /package/dist/lib/{browser → neutral}/index.mjs.map +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/types/hyperformula.ts
|
|
2
|
-
import { DetailedCellError, ExportedCellChange } from "
|
|
2
|
+
import { DetailedCellError, ExportedCellChange } from "@dxos/vendor-hyperformula";
|
|
3
3
|
|
|
4
4
|
// src/types/types.ts
|
|
5
5
|
import { invariant } from "@dxos/invariant";
|
|
@@ -77,10 +77,13 @@ var inRange = (range, cell) => {
|
|
|
77
77
|
// src/compute-node.ts
|
|
78
78
|
import { Event } from "@dxos/async";
|
|
79
79
|
import { Resource } from "@dxos/context";
|
|
80
|
-
import { DetailedCellError as DetailedCellError2 } from "
|
|
80
|
+
import { DetailedCellError as DetailedCellError2 } from "@dxos/vendor-hyperformula";
|
|
81
81
|
var ComputeNode = class extends Resource {
|
|
82
|
+
_graph;
|
|
83
|
+
sheetId;
|
|
84
|
+
update = new Event();
|
|
82
85
|
constructor(_graph, sheetId) {
|
|
83
|
-
super(), this._graph = _graph, this.sheetId = sheetId
|
|
86
|
+
super(), this._graph = _graph, this.sheetId = sheetId;
|
|
84
87
|
}
|
|
85
88
|
get graph() {
|
|
86
89
|
return this._graph;
|
|
@@ -120,14 +123,16 @@ var ComputeNode = class extends Resource {
|
|
|
120
123
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
121
124
|
import { debounce } from "@dxos/async";
|
|
122
125
|
import { log } from "@dxos/log";
|
|
123
|
-
import { CellError,
|
|
126
|
+
import { CellError, EmptyValue, ErrorType, FunctionPlugin } from "@dxos/vendor-hyperformula";
|
|
124
127
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/src/functions/async-function.ts";
|
|
125
128
|
var defaultFunctionContextOptions = {
|
|
126
129
|
defaultTtl: 5e3,
|
|
127
|
-
debounceDelay: 200
|
|
128
|
-
remoteFunctionUrl: "https://edge.dxos.workers.dev/functions"
|
|
130
|
+
debounceDelay: 200
|
|
129
131
|
};
|
|
130
132
|
var FunctionContext = class _FunctionContext {
|
|
133
|
+
_hf;
|
|
134
|
+
_runtime;
|
|
135
|
+
_space;
|
|
131
136
|
// Mangle name with params.
|
|
132
137
|
static createInvocationKey(name, ...args) {
|
|
133
138
|
return JSON.stringify({
|
|
@@ -135,13 +140,22 @@ var FunctionContext = class _FunctionContext {
|
|
|
135
140
|
...args
|
|
136
141
|
});
|
|
137
142
|
}
|
|
138
|
-
|
|
143
|
+
// TODO(wittjosiah): Persist cached values.
|
|
144
|
+
// Cached values for cell.
|
|
145
|
+
_cache = /* @__PURE__ */ new Map();
|
|
146
|
+
// Active requests.
|
|
147
|
+
_pending = /* @__PURE__ */ new Map();
|
|
148
|
+
// Query subscriptions.
|
|
149
|
+
_subscriptions = /* @__PURE__ */ new Map();
|
|
150
|
+
// Invocation count.
|
|
151
|
+
_invocations = {};
|
|
152
|
+
_options;
|
|
153
|
+
// Debounced update handler.
|
|
154
|
+
_onUpdate;
|
|
155
|
+
constructor(_hf, _runtime, _space, _options) {
|
|
139
156
|
this._hf = _hf;
|
|
157
|
+
this._runtime = _runtime;
|
|
140
158
|
this._space = _space;
|
|
141
|
-
this._cache = /* @__PURE__ */ new Map();
|
|
142
|
-
this._pending = /* @__PURE__ */ new Map();
|
|
143
|
-
this._subscriptions = /* @__PURE__ */ new Map();
|
|
144
|
-
this._invocations = {};
|
|
145
159
|
this._options = defaultsDeep(_options ?? {}, defaultFunctionContextOptions);
|
|
146
160
|
this._onUpdate = debounce((update) => {
|
|
147
161
|
log("update", update, {
|
|
@@ -157,15 +171,15 @@ var FunctionContext = class _FunctionContext {
|
|
|
157
171
|
get space() {
|
|
158
172
|
return this._space;
|
|
159
173
|
}
|
|
160
|
-
get remoteFunctionUrl() {
|
|
161
|
-
return this._options.remoteFunctionUrl;
|
|
162
|
-
}
|
|
163
174
|
get info() {
|
|
164
175
|
return {
|
|
165
176
|
cache: this._cache.size,
|
|
166
177
|
invocations: this._invocations
|
|
167
178
|
};
|
|
168
179
|
}
|
|
180
|
+
get runtime() {
|
|
181
|
+
return this._runtime;
|
|
182
|
+
}
|
|
169
183
|
flush() {
|
|
170
184
|
this._cache.clear();
|
|
171
185
|
this._invocations = {};
|
|
@@ -260,14 +274,14 @@ var AsyncFunctionPlugin = class extends FunctionPlugin {
|
|
|
260
274
|
};
|
|
261
275
|
|
|
262
276
|
// src/functions/edge-function.ts
|
|
263
|
-
import
|
|
264
|
-
import
|
|
265
|
-
import { Filter
|
|
266
|
-
import {
|
|
267
|
-
import { FunctionType, getUserFunctionUrlInMetadata } from "@dxos/functions";
|
|
277
|
+
import * as Effect from "effect/Effect";
|
|
278
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
279
|
+
import { Filter } from "@dxos/client/echo";
|
|
280
|
+
import { JsonSchema, Obj } from "@dxos/echo";
|
|
268
281
|
import { log as log2 } from "@dxos/log";
|
|
282
|
+
import { Operation } from "@dxos/operation";
|
|
269
283
|
import { isNonNullable } from "@dxos/util";
|
|
270
|
-
import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "
|
|
284
|
+
import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "@dxos/vendor-hyperformula";
|
|
271
285
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/src/functions/edge-function.ts";
|
|
272
286
|
var EDGE_FUNCTION_NAME = "DX";
|
|
273
287
|
var FUNCTION_TTL = 1e4;
|
|
@@ -278,7 +292,7 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
278
292
|
if (!space) {
|
|
279
293
|
return new CellError2(ErrorType2.REF, "Missing space");
|
|
280
294
|
}
|
|
281
|
-
const
|
|
295
|
+
const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, {
|
|
282
296
|
binding
|
|
283
297
|
})).run();
|
|
284
298
|
if (!fn) {
|
|
@@ -286,55 +300,44 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
286
300
|
binding
|
|
287
301
|
}, {
|
|
288
302
|
F: __dxlog_file3,
|
|
289
|
-
L:
|
|
303
|
+
L: 39,
|
|
290
304
|
S: this,
|
|
291
305
|
C: (f, a) => f(...a)
|
|
292
306
|
});
|
|
293
307
|
return new CellError2(ErrorType2.REF, "Function not found");
|
|
294
308
|
}
|
|
295
309
|
if (subscribe) {
|
|
296
|
-
const unsubscribe =
|
|
310
|
+
const unsubscribe = Obj.subscribe(fn, () => {
|
|
297
311
|
log2("function changed", {
|
|
298
312
|
fn
|
|
299
313
|
}, {
|
|
300
314
|
F: __dxlog_file3,
|
|
301
|
-
L:
|
|
315
|
+
L: 45,
|
|
302
316
|
S: this,
|
|
303
317
|
C: (f, a) => f(...a)
|
|
304
318
|
});
|
|
305
|
-
const _ = fn?.version;
|
|
306
319
|
this.runAsyncFunction(ast, state, handler(false), {
|
|
307
320
|
ttl: FUNCTION_TTL
|
|
308
321
|
});
|
|
309
322
|
});
|
|
310
323
|
this.context.createSubscription(ast.procedureName, unsubscribe);
|
|
311
324
|
}
|
|
312
|
-
const
|
|
325
|
+
const runtime = this.context.runtime;
|
|
326
|
+
const functionDef = Operation.deserialize(fn);
|
|
327
|
+
let input;
|
|
313
328
|
if (fn.inputSchema) {
|
|
314
|
-
const schema = toEffectSchema(fn.inputSchema);
|
|
315
|
-
SchemaAST.getPropertySignatures(schema.ast)
|
|
316
|
-
|
|
329
|
+
const schema = JsonSchema.toEffectSchema(fn.inputSchema);
|
|
330
|
+
const props = SchemaAST.getPropertySignatures(schema.ast);
|
|
331
|
+
input = {};
|
|
332
|
+
props.forEach(({ name }, index) => {
|
|
333
|
+
input[name.toString()] = args[index];
|
|
317
334
|
});
|
|
318
335
|
} else {
|
|
319
|
-
|
|
336
|
+
input = {
|
|
337
|
+
args: args.filter(isNonNullable)
|
|
338
|
+
};
|
|
320
339
|
}
|
|
321
|
-
const
|
|
322
|
-
const response = await fetch(`${this.context.remoteFunctionUrl}${path}`, {
|
|
323
|
-
method: "POST",
|
|
324
|
-
headers: {
|
|
325
|
-
"Content-Type": "application/json"
|
|
326
|
-
},
|
|
327
|
-
body: JSON.stringify(body)
|
|
328
|
-
});
|
|
329
|
-
const result = await response.text();
|
|
330
|
-
log2("function executed", {
|
|
331
|
-
result
|
|
332
|
-
}, {
|
|
333
|
-
F: __dxlog_file3,
|
|
334
|
-
L: 74,
|
|
335
|
-
S: this,
|
|
336
|
-
C: (f, a) => f(...a)
|
|
337
|
-
});
|
|
340
|
+
const result = runtime.runPromise(Operation.invoke(functionDef, input).pipe(Effect.orDie));
|
|
338
341
|
return result;
|
|
339
342
|
};
|
|
340
343
|
return this.runAsyncFunction(ast, state, handler(true), {
|
|
@@ -2772,16 +2775,15 @@ var defaultFunctions = [
|
|
|
2772
2775
|
|
|
2773
2776
|
// src/compute-graph.ts
|
|
2774
2777
|
import { Event as Event2 } from "@dxos/async";
|
|
2775
|
-
import { Filter as Filter2
|
|
2776
|
-
import { FQ_ID_LENGTH } from "@dxos/client/echo";
|
|
2778
|
+
import { Filter as Filter2 } from "@dxos/client/echo";
|
|
2777
2779
|
import { Resource as Resource2 } from "@dxos/context";
|
|
2778
|
-
import {
|
|
2779
|
-
import { FunctionType as FunctionType2 } from "@dxos/functions";
|
|
2780
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
2780
2781
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
2781
2782
|
import { PublicKey } from "@dxos/keys";
|
|
2782
2783
|
import { log as log3 } from "@dxos/log";
|
|
2784
|
+
import { Operation as Operation2 } from "@dxos/operation";
|
|
2783
2785
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
2784
|
-
import { ExportedCellChange as ExportedCellChange2 } from "
|
|
2786
|
+
import { ExportedCellChange as ExportedCellChange2 } from "@dxos/vendor-hyperformula";
|
|
2785
2787
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/src/compute-graph.ts";
|
|
2786
2788
|
var UNKNOWN_BINDING = "__UNKNOWN__";
|
|
2787
2789
|
var createSheetName = ({ type, id }) => `${type}@${id}`;
|
|
@@ -2795,9 +2797,21 @@ var parseSheetName = (name) => {
|
|
|
2795
2797
|
};
|
|
2796
2798
|
};
|
|
2797
2799
|
var ComputeGraph = class extends Resource2 {
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2800
|
+
_hf;
|
|
2801
|
+
_runtime;
|
|
2802
|
+
_space;
|
|
2803
|
+
_options;
|
|
2804
|
+
id = `graph-${PublicKey.random().truncate()}`;
|
|
2805
|
+
// Map of nodes indexed by sheet number.
|
|
2806
|
+
_nodes = /* @__PURE__ */ new Map();
|
|
2807
|
+
// Cached function objects.
|
|
2808
|
+
_remoteFunctions = [];
|
|
2809
|
+
update = new Event2();
|
|
2810
|
+
// The context is passed to all functions.
|
|
2811
|
+
context;
|
|
2812
|
+
constructor(_hf, _runtime, _space, _options) {
|
|
2813
|
+
super(), this._hf = _hf, this._runtime = _runtime, this._space = _space, this._options = _options;
|
|
2814
|
+
this.context = new FunctionContext(this._hf, this._runtime, this._space, {
|
|
2801
2815
|
...this._options,
|
|
2802
2816
|
onUpdate: (update) => {
|
|
2803
2817
|
this._options?.onUpdate?.(update);
|
|
@@ -2853,7 +2867,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2853
2867
|
getOrCreateNode(name) {
|
|
2854
2868
|
invariant2(name.length, void 0, {
|
|
2855
2869
|
F: __dxlog_file4,
|
|
2856
|
-
L:
|
|
2870
|
+
L: 132,
|
|
2857
2871
|
S: this,
|
|
2858
2872
|
A: [
|
|
2859
2873
|
"name.length",
|
|
@@ -2866,7 +2880,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2866
2880
|
sheet: name
|
|
2867
2881
|
}, {
|
|
2868
2882
|
F: __dxlog_file4,
|
|
2869
|
-
L:
|
|
2883
|
+
L: 134,
|
|
2870
2884
|
S: this,
|
|
2871
2885
|
C: (f, a) => f(...a)
|
|
2872
2886
|
});
|
|
@@ -2875,7 +2889,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2875
2889
|
const sheetId = this._hf.getSheetId(name);
|
|
2876
2890
|
invariant2(sheetId !== void 0, void 0, {
|
|
2877
2891
|
F: __dxlog_file4,
|
|
2878
|
-
L:
|
|
2892
|
+
L: 139,
|
|
2879
2893
|
S: this,
|
|
2880
2894
|
A: [
|
|
2881
2895
|
"sheetId !== undefined",
|
|
@@ -2899,7 +2913,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2899
2913
|
}).filter(isNonNullable2);
|
|
2900
2914
|
for (const obj of objects) {
|
|
2901
2915
|
if (obj.name === name) {
|
|
2902
|
-
const type = getTypename(obj);
|
|
2916
|
+
const type = Obj2.getTypename(obj);
|
|
2903
2917
|
return `'${createSheetName({
|
|
2904
2918
|
type,
|
|
2905
2919
|
id: obj.id
|
|
@@ -2921,8 +2935,8 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2921
2935
|
});
|
|
2922
2936
|
}
|
|
2923
2937
|
/**
|
|
2924
|
-
* Map from binding to fully qualified ECHO
|
|
2925
|
-
* E.g., HELLO() => spaceId:objectId()
|
|
2938
|
+
* Map from binding to fully qualified ECHO DXN (to store).
|
|
2939
|
+
* E.g., HELLO() => dxn:echo:spaceId:objectId()
|
|
2926
2940
|
*/
|
|
2927
2941
|
mapFunctionBindingToId(formula) {
|
|
2928
2942
|
return formula.replace(/(\w+)\((.*)\)/g, (match, binding, args) => {
|
|
@@ -2931,7 +2945,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2931
2945
|
}
|
|
2932
2946
|
const fn = this._remoteFunctions.find((fn2) => fn2.binding === binding);
|
|
2933
2947
|
if (fn) {
|
|
2934
|
-
const id =
|
|
2948
|
+
const id = Obj2.getDXN(fn).toString();
|
|
2935
2949
|
return `${id}(${args})`;
|
|
2936
2950
|
} else {
|
|
2937
2951
|
return match;
|
|
@@ -2939,16 +2953,13 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2939
2953
|
});
|
|
2940
2954
|
}
|
|
2941
2955
|
/**
|
|
2942
|
-
* Map from fully qualified ECHO
|
|
2943
|
-
* E.g., spaceId:objectId() => HELLO()
|
|
2956
|
+
* Map from fully qualified ECHO DXN to binding (from store).
|
|
2957
|
+
* E.g., dxn:echo:spaceId:objectId() => HELLO()
|
|
2944
2958
|
*/
|
|
2945
2959
|
mapFunctionBindingFromId(formula) {
|
|
2946
|
-
const binding = formula.replace(/(
|
|
2947
|
-
const
|
|
2948
|
-
|
|
2949
|
-
return match;
|
|
2950
|
-
}
|
|
2951
|
-
const fn = this._remoteFunctions.find((fn2) => fullyQualifiedId(fn2) === id);
|
|
2960
|
+
const binding = formula.replace(/dxn:([^:]+):([^:(]+):([a-zA-Z0-9]+)\((.*)\)/g, (_match, kind, spaceTag, objectId, args) => {
|
|
2961
|
+
const dxn = `dxn:${kind}:${spaceTag}:${objectId}`;
|
|
2962
|
+
const fn = this._remoteFunctions.find((fn2) => Obj2.getDXN(fn2).toString() === dxn);
|
|
2952
2963
|
if (fn?.binding) {
|
|
2953
2964
|
return `${fn.binding}(${args})`;
|
|
2954
2965
|
} else {
|
|
@@ -2963,12 +2974,14 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2963
2974
|
}
|
|
2964
2975
|
async _open() {
|
|
2965
2976
|
if (this._space) {
|
|
2966
|
-
const query = this._space.db.query(Filter2.type(
|
|
2967
|
-
const unsubscribe = query.subscribe((
|
|
2968
|
-
this._remoteFunctions =
|
|
2977
|
+
const query = this._space.db.query(Filter2.type(Operation2.PersistentOperation));
|
|
2978
|
+
const unsubscribe = query.subscribe(() => {
|
|
2979
|
+
this._remoteFunctions = query.results.filter((fn) => fn.binding);
|
|
2969
2980
|
this.update.emit({
|
|
2970
2981
|
type: "functionsUpdated"
|
|
2971
2982
|
});
|
|
2983
|
+
}, {
|
|
2984
|
+
fire: true
|
|
2972
2985
|
});
|
|
2973
2986
|
this._ctx.onDispose(unsubscribe);
|
|
2974
2987
|
}
|
|
@@ -2985,24 +2998,24 @@ import defaultsDeep2 from "lodash.defaultsdeep";
|
|
|
2985
2998
|
import { Resource as Resource3 } from "@dxos/context";
|
|
2986
2999
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2987
3000
|
import { log as log4 } from "@dxos/log";
|
|
2988
|
-
import { HyperFormula } from "
|
|
3001
|
+
import { HyperFormula } from "@dxos/vendor-hyperformula";
|
|
2989
3002
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/src/compute-graph-registry.ts";
|
|
2990
|
-
var defaultOptions = {
|
|
2991
|
-
licenseKey: "gpl-v3"
|
|
2992
|
-
};
|
|
2993
3003
|
var defaultPlugins = [
|
|
2994
3004
|
{
|
|
2995
3005
|
plugin: EdgeFunctionPlugin,
|
|
2996
3006
|
translations: EdgeFunctionPluginTranslations
|
|
2997
3007
|
}
|
|
2998
3008
|
];
|
|
3009
|
+
var defaultOptions = {
|
|
3010
|
+
licenseKey: "gpl-v3"
|
|
3011
|
+
};
|
|
2999
3012
|
var ComputeGraphRegistry = class extends Resource3 {
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3013
|
+
_graphs = /* @__PURE__ */ new Map();
|
|
3014
|
+
_options;
|
|
3015
|
+
constructor(options) {
|
|
3003
3016
|
super();
|
|
3004
|
-
this._graphs = /* @__PURE__ */ new Map();
|
|
3005
3017
|
this._options = defaultsDeep2({}, options, defaultOptions);
|
|
3018
|
+
this._options.plugins = this._options.plugins ?? defaultPlugins;
|
|
3006
3019
|
this._options.plugins?.forEach(({ plugin, translations }) => {
|
|
3007
3020
|
HyperFormula.registerFunctionPlugin(plugin, translations);
|
|
3008
3021
|
});
|
|
@@ -3017,7 +3030,7 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3017
3030
|
space: space.id
|
|
3018
3031
|
}, {
|
|
3019
3032
|
F: __dxlog_file5,
|
|
3020
|
-
L:
|
|
3033
|
+
L: 73,
|
|
3021
3034
|
S: this,
|
|
3022
3035
|
C: (f, a) => f(...a)
|
|
3023
3036
|
});
|
|
@@ -3028,7 +3041,7 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3028
3041
|
createGraph(space) {
|
|
3029
3042
|
invariant3(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`, {
|
|
3030
3043
|
F: __dxlog_file5,
|
|
3031
|
-
L:
|
|
3044
|
+
L: 81,
|
|
3032
3045
|
S: this,
|
|
3033
3046
|
A: [
|
|
3034
3047
|
"!this._graphs.has(space.id)",
|
|
@@ -3036,7 +3049,17 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3036
3049
|
]
|
|
3037
3050
|
});
|
|
3038
3051
|
const hf = HyperFormula.buildEmpty(this._options);
|
|
3039
|
-
|
|
3052
|
+
invariant3(this._options.computeRuntime, "ComputeRuntime is required", {
|
|
3053
|
+
F: __dxlog_file5,
|
|
3054
|
+
L: 83,
|
|
3055
|
+
S: this,
|
|
3056
|
+
A: [
|
|
3057
|
+
"this._options.computeRuntime",
|
|
3058
|
+
"'ComputeRuntime is required'"
|
|
3059
|
+
]
|
|
3060
|
+
});
|
|
3061
|
+
const runtime = this._options.computeRuntime.getRuntime(space.id);
|
|
3062
|
+
const graph = new ComputeGraph(hf, runtime, space, this._options);
|
|
3040
3063
|
this._graphs.set(space.id, graph);
|
|
3041
3064
|
return graph;
|
|
3042
3065
|
}
|
|
@@ -3071,8 +3094,8 @@ export {
|
|
|
3071
3094
|
createSheetName,
|
|
3072
3095
|
parseSheetName,
|
|
3073
3096
|
ComputeGraph,
|
|
3074
|
-
defaultOptions,
|
|
3075
3097
|
defaultPlugins,
|
|
3098
|
+
defaultOptions,
|
|
3076
3099
|
ComputeGraphRegistry
|
|
3077
3100
|
};
|
|
3078
|
-
//# sourceMappingURL=chunk-
|
|
3101
|
+
//# sourceMappingURL=chunk-JRV42MW3.mjs.map
|