@dxos/compute 0.8.4-main.b97322e → 0.8.4-main.bcb3aa67d6
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-AURNYRCC.mjs → neutral/chunk-23PT47U5.mjs} +112 -86
- package/dist/lib/neutral/chunk-23PT47U5.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 +31 -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 -14
- package/src/compute-graph.test.ts +63 -13
- package/src/compute-graph.ts +44 -38
- package/src/compute-node.ts +2 -5
- package/src/functions/async-function.ts +21 -16
- package/src/functions/edge-function.ts +33 -32
- 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 +8 -2
- package/src/testing/test-plugin.ts +2 -5
- package/src/testing/test-runtime.ts +36 -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-AURNYRCC.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-DZMSWKOY.mjs +0 -3080
- package/dist/lib/node-esm/chunk-DZMSWKOY.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,15 @@ 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 {
|
|
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";
|
|
281
|
+
import { FunctionInvocationService, TracingService } from "@dxos/functions";
|
|
282
|
+
import { Operation } from "@dxos/operation";
|
|
268
283
|
import { log as log2 } from "@dxos/log";
|
|
269
284
|
import { isNonNullable } from "@dxos/util";
|
|
270
|
-
import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "
|
|
285
|
+
import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "@dxos/vendor-hyperformula";
|
|
271
286
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/src/functions/edge-function.ts";
|
|
272
287
|
var EDGE_FUNCTION_NAME = "DX";
|
|
273
288
|
var FUNCTION_TTL = 1e4;
|
|
@@ -278,7 +293,7 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
278
293
|
if (!space) {
|
|
279
294
|
return new CellError2(ErrorType2.REF, "Missing space");
|
|
280
295
|
}
|
|
281
|
-
const
|
|
296
|
+
const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, {
|
|
282
297
|
binding
|
|
283
298
|
})).run();
|
|
284
299
|
if (!fn) {
|
|
@@ -286,55 +301,46 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
286
301
|
binding
|
|
287
302
|
}, {
|
|
288
303
|
F: __dxlog_file3,
|
|
289
|
-
L:
|
|
304
|
+
L: 40,
|
|
290
305
|
S: this,
|
|
291
306
|
C: (f, a) => f(...a)
|
|
292
307
|
});
|
|
293
308
|
return new CellError2(ErrorType2.REF, "Function not found");
|
|
294
309
|
}
|
|
295
310
|
if (subscribe) {
|
|
296
|
-
const unsubscribe =
|
|
311
|
+
const unsubscribe = Obj.subscribe(fn, () => {
|
|
297
312
|
log2("function changed", {
|
|
298
313
|
fn
|
|
299
314
|
}, {
|
|
300
315
|
F: __dxlog_file3,
|
|
301
|
-
L:
|
|
316
|
+
L: 46,
|
|
302
317
|
S: this,
|
|
303
318
|
C: (f, a) => f(...a)
|
|
304
319
|
});
|
|
305
|
-
const _ = fn?.version;
|
|
306
320
|
this.runAsyncFunction(ast, state, handler(false), {
|
|
307
321
|
ttl: FUNCTION_TTL
|
|
308
322
|
});
|
|
309
323
|
});
|
|
310
324
|
this.context.createSubscription(ast.procedureName, unsubscribe);
|
|
311
325
|
}
|
|
312
|
-
const
|
|
326
|
+
const runtime = this.context.runtime;
|
|
327
|
+
const functionDef = Operation.deserialize(fn);
|
|
328
|
+
let input;
|
|
313
329
|
if (fn.inputSchema) {
|
|
314
|
-
const schema = toEffectSchema(fn.inputSchema);
|
|
315
|
-
SchemaAST.getPropertySignatures(schema.ast)
|
|
316
|
-
|
|
330
|
+
const schema = JsonSchema.toEffectSchema(fn.inputSchema);
|
|
331
|
+
const props = SchemaAST.getPropertySignatures(schema.ast);
|
|
332
|
+
input = {};
|
|
333
|
+
props.forEach(({ name }, index) => {
|
|
334
|
+
input[name.toString()] = args[index];
|
|
317
335
|
});
|
|
318
336
|
} else {
|
|
319
|
-
|
|
337
|
+
input = {
|
|
338
|
+
args: args.filter(isNonNullable)
|
|
339
|
+
};
|
|
320
340
|
}
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
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: 75,
|
|
335
|
-
S: this,
|
|
336
|
-
C: (f, a) => f(...a)
|
|
337
|
-
});
|
|
341
|
+
const result = runtime.runPromise(Effect.gen(function* () {
|
|
342
|
+
return yield* FunctionInvocationService.invokeFunction(functionDef, input);
|
|
343
|
+
}).pipe(Effect.provide(TracingService.layerNoop)));
|
|
338
344
|
return result;
|
|
339
345
|
};
|
|
340
346
|
return this.runAsyncFunction(ast, state, handler(true), {
|
|
@@ -2772,16 +2778,15 @@ var defaultFunctions = [
|
|
|
2772
2778
|
|
|
2773
2779
|
// src/compute-graph.ts
|
|
2774
2780
|
import { Event as Event2 } from "@dxos/async";
|
|
2775
|
-
import { Filter as Filter2
|
|
2776
|
-
import { FQ_ID_LENGTH } from "@dxos/client/echo";
|
|
2781
|
+
import { Filter as Filter2 } from "@dxos/client/echo";
|
|
2777
2782
|
import { Resource as Resource2 } from "@dxos/context";
|
|
2778
|
-
import {
|
|
2779
|
-
import {
|
|
2783
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
2784
|
+
import { Operation as Operation2 } from "@dxos/operation";
|
|
2780
2785
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
2781
2786
|
import { PublicKey } from "@dxos/keys";
|
|
2782
2787
|
import { log as log3 } from "@dxos/log";
|
|
2783
2788
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
2784
|
-
import { ExportedCellChange as ExportedCellChange2 } from "
|
|
2789
|
+
import { ExportedCellChange as ExportedCellChange2 } from "@dxos/vendor-hyperformula";
|
|
2785
2790
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/src/compute-graph.ts";
|
|
2786
2791
|
var UNKNOWN_BINDING = "__UNKNOWN__";
|
|
2787
2792
|
var createSheetName = ({ type, id }) => `${type}@${id}`;
|
|
@@ -2795,9 +2800,21 @@ var parseSheetName = (name) => {
|
|
|
2795
2800
|
};
|
|
2796
2801
|
};
|
|
2797
2802
|
var ComputeGraph = class extends Resource2 {
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2803
|
+
_hf;
|
|
2804
|
+
_runtime;
|
|
2805
|
+
_space;
|
|
2806
|
+
_options;
|
|
2807
|
+
id = `graph-${PublicKey.random().truncate()}`;
|
|
2808
|
+
// Map of nodes indexed by sheet number.
|
|
2809
|
+
_nodes = /* @__PURE__ */ new Map();
|
|
2810
|
+
// Cached function objects.
|
|
2811
|
+
_remoteFunctions = [];
|
|
2812
|
+
update = new Event2();
|
|
2813
|
+
// The context is passed to all functions.
|
|
2814
|
+
context;
|
|
2815
|
+
constructor(_hf, _runtime, _space, _options) {
|
|
2816
|
+
super(), this._hf = _hf, this._runtime = _runtime, this._space = _space, this._options = _options;
|
|
2817
|
+
this.context = new FunctionContext(this._hf, this._runtime, this._space, {
|
|
2801
2818
|
...this._options,
|
|
2802
2819
|
onUpdate: (update) => {
|
|
2803
2820
|
this._options?.onUpdate?.(update);
|
|
@@ -2853,7 +2870,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2853
2870
|
getOrCreateNode(name) {
|
|
2854
2871
|
invariant2(name.length, void 0, {
|
|
2855
2872
|
F: __dxlog_file4,
|
|
2856
|
-
L:
|
|
2873
|
+
L: 133,
|
|
2857
2874
|
S: this,
|
|
2858
2875
|
A: [
|
|
2859
2876
|
"name.length",
|
|
@@ -2866,7 +2883,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2866
2883
|
sheet: name
|
|
2867
2884
|
}, {
|
|
2868
2885
|
F: __dxlog_file4,
|
|
2869
|
-
L:
|
|
2886
|
+
L: 135,
|
|
2870
2887
|
S: this,
|
|
2871
2888
|
C: (f, a) => f(...a)
|
|
2872
2889
|
});
|
|
@@ -2875,7 +2892,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2875
2892
|
const sheetId = this._hf.getSheetId(name);
|
|
2876
2893
|
invariant2(sheetId !== void 0, void 0, {
|
|
2877
2894
|
F: __dxlog_file4,
|
|
2878
|
-
L:
|
|
2895
|
+
L: 140,
|
|
2879
2896
|
S: this,
|
|
2880
2897
|
A: [
|
|
2881
2898
|
"sheetId !== undefined",
|
|
@@ -2899,7 +2916,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2899
2916
|
}).filter(isNonNullable2);
|
|
2900
2917
|
for (const obj of objects) {
|
|
2901
2918
|
if (obj.name === name) {
|
|
2902
|
-
const type = getTypename(obj);
|
|
2919
|
+
const type = Obj2.getTypename(obj);
|
|
2903
2920
|
return `'${createSheetName({
|
|
2904
2921
|
type,
|
|
2905
2922
|
id: obj.id
|
|
@@ -2921,8 +2938,8 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2921
2938
|
});
|
|
2922
2939
|
}
|
|
2923
2940
|
/**
|
|
2924
|
-
* Map from binding to fully qualified ECHO
|
|
2925
|
-
* E.g., HELLO() => spaceId:objectId()
|
|
2941
|
+
* Map from binding to fully qualified ECHO DXN (to store).
|
|
2942
|
+
* E.g., HELLO() => dxn:echo:spaceId:objectId()
|
|
2926
2943
|
*/
|
|
2927
2944
|
mapFunctionBindingToId(formula) {
|
|
2928
2945
|
return formula.replace(/(\w+)\((.*)\)/g, (match, binding, args) => {
|
|
@@ -2931,7 +2948,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2931
2948
|
}
|
|
2932
2949
|
const fn = this._remoteFunctions.find((fn2) => fn2.binding === binding);
|
|
2933
2950
|
if (fn) {
|
|
2934
|
-
const id =
|
|
2951
|
+
const id = Obj2.getDXN(fn).toString();
|
|
2935
2952
|
return `${id}(${args})`;
|
|
2936
2953
|
} else {
|
|
2937
2954
|
return match;
|
|
@@ -2939,16 +2956,13 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2939
2956
|
});
|
|
2940
2957
|
}
|
|
2941
2958
|
/**
|
|
2942
|
-
* Map from fully qualified ECHO
|
|
2943
|
-
* E.g., spaceId:objectId() => HELLO()
|
|
2959
|
+
* Map from fully qualified ECHO DXN to binding (from store).
|
|
2960
|
+
* E.g., dxn:echo:spaceId:objectId() => HELLO()
|
|
2944
2961
|
*/
|
|
2945
2962
|
mapFunctionBindingFromId(formula) {
|
|
2946
|
-
const binding = formula.replace(/(
|
|
2947
|
-
const
|
|
2948
|
-
|
|
2949
|
-
return match;
|
|
2950
|
-
}
|
|
2951
|
-
const fn = this._remoteFunctions.find((fn2) => fullyQualifiedId(fn2) === id);
|
|
2963
|
+
const binding = formula.replace(/dxn:([^:]+):([^:(]+):([a-zA-Z0-9]+)\((.*)\)/g, (_match, kind, spaceTag, objectId, args) => {
|
|
2964
|
+
const dxn = `dxn:${kind}:${spaceTag}:${objectId}`;
|
|
2965
|
+
const fn = this._remoteFunctions.find((fn2) => Obj2.getDXN(fn2).toString() === dxn);
|
|
2952
2966
|
if (fn?.binding) {
|
|
2953
2967
|
return `${fn.binding}(${args})`;
|
|
2954
2968
|
} else {
|
|
@@ -2963,12 +2977,14 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2963
2977
|
}
|
|
2964
2978
|
async _open() {
|
|
2965
2979
|
if (this._space) {
|
|
2966
|
-
const query = this._space.db.query(Filter2.type(
|
|
2967
|
-
const unsubscribe = query.subscribe((
|
|
2968
|
-
this._remoteFunctions =
|
|
2980
|
+
const query = this._space.db.query(Filter2.type(Operation2.PersistentOperation));
|
|
2981
|
+
const unsubscribe = query.subscribe(() => {
|
|
2982
|
+
this._remoteFunctions = query.results.filter((fn) => fn.binding);
|
|
2969
2983
|
this.update.emit({
|
|
2970
2984
|
type: "functionsUpdated"
|
|
2971
2985
|
});
|
|
2986
|
+
}, {
|
|
2987
|
+
fire: true
|
|
2972
2988
|
});
|
|
2973
2989
|
this._ctx.onDispose(unsubscribe);
|
|
2974
2990
|
}
|
|
@@ -2985,24 +3001,24 @@ import defaultsDeep2 from "lodash.defaultsdeep";
|
|
|
2985
3001
|
import { Resource as Resource3 } from "@dxos/context";
|
|
2986
3002
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2987
3003
|
import { log as log4 } from "@dxos/log";
|
|
2988
|
-
import { HyperFormula } from "
|
|
3004
|
+
import { HyperFormula } from "@dxos/vendor-hyperformula";
|
|
2989
3005
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/src/compute-graph-registry.ts";
|
|
2990
|
-
var defaultOptions = {
|
|
2991
|
-
licenseKey: "gpl-v3"
|
|
2992
|
-
};
|
|
2993
3006
|
var defaultPlugins = [
|
|
2994
3007
|
{
|
|
2995
3008
|
plugin: EdgeFunctionPlugin,
|
|
2996
3009
|
translations: EdgeFunctionPluginTranslations
|
|
2997
3010
|
}
|
|
2998
3011
|
];
|
|
3012
|
+
var defaultOptions = {
|
|
3013
|
+
licenseKey: "gpl-v3"
|
|
3014
|
+
};
|
|
2999
3015
|
var ComputeGraphRegistry = class extends Resource3 {
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3016
|
+
_graphs = /* @__PURE__ */ new Map();
|
|
3017
|
+
_options;
|
|
3018
|
+
constructor(options) {
|
|
3003
3019
|
super();
|
|
3004
|
-
this._graphs = /* @__PURE__ */ new Map();
|
|
3005
3020
|
this._options = defaultsDeep2({}, options, defaultOptions);
|
|
3021
|
+
this._options.plugins = this._options.plugins ?? defaultPlugins;
|
|
3006
3022
|
this._options.plugins?.forEach(({ plugin, translations }) => {
|
|
3007
3023
|
HyperFormula.registerFunctionPlugin(plugin, translations);
|
|
3008
3024
|
});
|
|
@@ -3017,7 +3033,7 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3017
3033
|
space: space.id
|
|
3018
3034
|
}, {
|
|
3019
3035
|
F: __dxlog_file5,
|
|
3020
|
-
L:
|
|
3036
|
+
L: 73,
|
|
3021
3037
|
S: this,
|
|
3022
3038
|
C: (f, a) => f(...a)
|
|
3023
3039
|
});
|
|
@@ -3028,7 +3044,7 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3028
3044
|
createGraph(space) {
|
|
3029
3045
|
invariant3(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`, {
|
|
3030
3046
|
F: __dxlog_file5,
|
|
3031
|
-
L:
|
|
3047
|
+
L: 81,
|
|
3032
3048
|
S: this,
|
|
3033
3049
|
A: [
|
|
3034
3050
|
"!this._graphs.has(space.id)",
|
|
@@ -3036,7 +3052,17 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3036
3052
|
]
|
|
3037
3053
|
});
|
|
3038
3054
|
const hf = HyperFormula.buildEmpty(this._options);
|
|
3039
|
-
|
|
3055
|
+
invariant3(this._options.computeRuntime, "ComputeRuntime is required", {
|
|
3056
|
+
F: __dxlog_file5,
|
|
3057
|
+
L: 83,
|
|
3058
|
+
S: this,
|
|
3059
|
+
A: [
|
|
3060
|
+
"this._options.computeRuntime",
|
|
3061
|
+
"'ComputeRuntime is required'"
|
|
3062
|
+
]
|
|
3063
|
+
});
|
|
3064
|
+
const runtime = this._options.computeRuntime.getRuntime(space.id);
|
|
3065
|
+
const graph = new ComputeGraph(hf, runtime, space, this._options);
|
|
3040
3066
|
this._graphs.set(space.id, graph);
|
|
3041
3067
|
return graph;
|
|
3042
3068
|
}
|
|
@@ -3071,8 +3097,8 @@ export {
|
|
|
3071
3097
|
createSheetName,
|
|
3072
3098
|
parseSheetName,
|
|
3073
3099
|
ComputeGraph,
|
|
3074
|
-
defaultOptions,
|
|
3075
3100
|
defaultPlugins,
|
|
3101
|
+
defaultOptions,
|
|
3076
3102
|
ComputeGraphRegistry
|
|
3077
3103
|
};
|
|
3078
|
-
//# sourceMappingURL=chunk-
|
|
3104
|
+
//# sourceMappingURL=chunk-23PT47U5.mjs.map
|