@dxos/compute 0.8.4-main.b97322e → 0.8.4-main.c4373fc
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 → chunk-C7KLV2IU.mjs} +179 -113
- package/dist/lib/browser/chunk-C7KLV2IU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +42 -9
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/{chunk-DZMSWKOY.mjs → chunk-K37OSZ5O.mjs} +179 -113
- package/dist/lib/node-esm/chunk-K37OSZ5O.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +42 -9
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- 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 +5 -2
- 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/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 +24 -28
- package/src/compute-graph-registry.test.ts +138 -0
- package/src/compute-graph-registry.ts +20 -14
- package/src/compute-graph.test.ts +2 -3
- package/src/compute-graph.ts +10 -9
- package/src/compute-node.ts +2 -5
- package/src/functions/async-function.ts +21 -16
- package/src/functions/edge-function.ts +24 -22
- package/src/hyperformula.test.ts +2 -2
- 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 +38 -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/node-esm/chunk-DZMSWKOY.mjs.map +0 -7
- package/dist/vendor/hyperformula.mjs +0 -36400
|
@@ -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,11 +77,21 @@ 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 "
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
import { DetailedCellError as DetailedCellError2 } from "@dxos/vendor-hyperformula";
|
|
81
|
+
function _define_property(obj, key, value) {
|
|
82
|
+
if (key in obj) {
|
|
83
|
+
Object.defineProperty(obj, key, {
|
|
84
|
+
value,
|
|
85
|
+
enumerable: true,
|
|
86
|
+
configurable: true,
|
|
87
|
+
writable: true
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
obj[key] = value;
|
|
84
91
|
}
|
|
92
|
+
return obj;
|
|
93
|
+
}
|
|
94
|
+
var ComputeNode = class extends Resource {
|
|
85
95
|
get graph() {
|
|
86
96
|
return this._graph;
|
|
87
97
|
}
|
|
@@ -114,18 +124,33 @@ var ComputeNode = class extends Resource {
|
|
|
114
124
|
// TODO(burdon): Load data into sheet.
|
|
115
125
|
async _open() {
|
|
116
126
|
}
|
|
127
|
+
constructor(_graph, sheetId) {
|
|
128
|
+
super(), _define_property(this, "_graph", void 0), _define_property(this, "sheetId", void 0), _define_property(this, "update", void 0), this._graph = _graph, this.sheetId = sheetId, this.update = new Event();
|
|
129
|
+
}
|
|
117
130
|
};
|
|
118
131
|
|
|
119
132
|
// src/functions/async-function.ts
|
|
120
133
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
121
134
|
import { debounce } from "@dxos/async";
|
|
122
135
|
import { log } from "@dxos/log";
|
|
123
|
-
import { CellError,
|
|
136
|
+
import { CellError, EmptyValue, ErrorType, FunctionPlugin } from "@dxos/vendor-hyperformula";
|
|
137
|
+
function _define_property2(obj, key, value) {
|
|
138
|
+
if (key in obj) {
|
|
139
|
+
Object.defineProperty(obj, key, {
|
|
140
|
+
value,
|
|
141
|
+
enumerable: true,
|
|
142
|
+
configurable: true,
|
|
143
|
+
writable: true
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
obj[key] = value;
|
|
147
|
+
}
|
|
148
|
+
return obj;
|
|
149
|
+
}
|
|
124
150
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/src/functions/async-function.ts";
|
|
125
151
|
var defaultFunctionContextOptions = {
|
|
126
152
|
defaultTtl: 5e3,
|
|
127
|
-
debounceDelay: 200
|
|
128
|
-
remoteFunctionUrl: "https://edge.dxos.workers.dev/functions"
|
|
153
|
+
debounceDelay: 200
|
|
129
154
|
};
|
|
130
155
|
var FunctionContext = class _FunctionContext {
|
|
131
156
|
// Mangle name with params.
|
|
@@ -135,37 +160,18 @@ var FunctionContext = class _FunctionContext {
|
|
|
135
160
|
...args
|
|
136
161
|
});
|
|
137
162
|
}
|
|
138
|
-
constructor(_hf, _space, _options) {
|
|
139
|
-
this._hf = _hf;
|
|
140
|
-
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
|
-
this._options = defaultsDeep(_options ?? {}, defaultFunctionContextOptions);
|
|
146
|
-
this._onUpdate = debounce((update) => {
|
|
147
|
-
log("update", update, {
|
|
148
|
-
F: __dxlog_file2,
|
|
149
|
-
L: 86,
|
|
150
|
-
S: this,
|
|
151
|
-
C: (f, a) => f(...a)
|
|
152
|
-
});
|
|
153
|
-
this._hf.resumeEvaluation();
|
|
154
|
-
this._options.onUpdate?.(update);
|
|
155
|
-
}, this._options.debounceDelay);
|
|
156
|
-
}
|
|
157
163
|
get space() {
|
|
158
164
|
return this._space;
|
|
159
165
|
}
|
|
160
|
-
get remoteFunctionUrl() {
|
|
161
|
-
return this._options.remoteFunctionUrl;
|
|
162
|
-
}
|
|
163
166
|
get info() {
|
|
164
167
|
return {
|
|
165
168
|
cache: this._cache.size,
|
|
166
169
|
invocations: this._invocations
|
|
167
170
|
};
|
|
168
171
|
}
|
|
172
|
+
get runtime() {
|
|
173
|
+
return this._runtime;
|
|
174
|
+
}
|
|
169
175
|
flush() {
|
|
170
176
|
this._cache.clear();
|
|
171
177
|
this._invocations = {};
|
|
@@ -242,6 +248,35 @@ var FunctionContext = class _FunctionContext {
|
|
|
242
248
|
});
|
|
243
249
|
return value;
|
|
244
250
|
}
|
|
251
|
+
constructor(_hf, _runtime, _space, _options) {
|
|
252
|
+
_define_property2(this, "_hf", void 0);
|
|
253
|
+
_define_property2(this, "_runtime", void 0);
|
|
254
|
+
_define_property2(this, "_space", void 0);
|
|
255
|
+
_define_property2(this, "_cache", void 0);
|
|
256
|
+
_define_property2(this, "_pending", void 0);
|
|
257
|
+
_define_property2(this, "_subscriptions", void 0);
|
|
258
|
+
_define_property2(this, "_invocations", void 0);
|
|
259
|
+
_define_property2(this, "_options", void 0);
|
|
260
|
+
_define_property2(this, "_onUpdate", void 0);
|
|
261
|
+
this._hf = _hf;
|
|
262
|
+
this._runtime = _runtime;
|
|
263
|
+
this._space = _space;
|
|
264
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
265
|
+
this._pending = /* @__PURE__ */ new Map();
|
|
266
|
+
this._subscriptions = /* @__PURE__ */ new Map();
|
|
267
|
+
this._invocations = {};
|
|
268
|
+
this._options = defaultsDeep(_options ?? {}, defaultFunctionContextOptions);
|
|
269
|
+
this._onUpdate = debounce((update) => {
|
|
270
|
+
log("update", update, {
|
|
271
|
+
F: __dxlog_file2,
|
|
272
|
+
L: 86,
|
|
273
|
+
S: this,
|
|
274
|
+
C: (f, a) => f(...a)
|
|
275
|
+
});
|
|
276
|
+
this._hf.resumeEvaluation();
|
|
277
|
+
this._options.onUpdate?.(update);
|
|
278
|
+
}, this._options.debounceDelay);
|
|
279
|
+
}
|
|
245
280
|
};
|
|
246
281
|
var AsyncFunctionPlugin = class extends FunctionPlugin {
|
|
247
282
|
get context() {
|
|
@@ -261,13 +296,15 @@ var AsyncFunctionPlugin = class extends FunctionPlugin {
|
|
|
261
296
|
|
|
262
297
|
// src/functions/edge-function.ts
|
|
263
298
|
import { effect } from "@preact/signals-core";
|
|
264
|
-
import
|
|
265
|
-
import
|
|
266
|
-
import {
|
|
267
|
-
import {
|
|
299
|
+
import * as Effect from "effect/Effect";
|
|
300
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
301
|
+
import { Filter } from "@dxos/client/echo";
|
|
302
|
+
import { toEffectSchema } from "@dxos/echo/internal";
|
|
303
|
+
import { ComputeEventLogger, FunctionInvocationService, FunctionType, TracingService } from "@dxos/functions";
|
|
304
|
+
import { FunctionDefinition } from "@dxos/functions";
|
|
268
305
|
import { log as log2 } from "@dxos/log";
|
|
269
306
|
import { isNonNullable } from "@dxos/util";
|
|
270
|
-
import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "
|
|
307
|
+
import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "@dxos/vendor-hyperformula";
|
|
271
308
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/src/functions/edge-function.ts";
|
|
272
309
|
var EDGE_FUNCTION_NAME = "DX";
|
|
273
310
|
var FUNCTION_TTL = 1e4;
|
|
@@ -286,7 +323,7 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
286
323
|
binding
|
|
287
324
|
}, {
|
|
288
325
|
F: __dxlog_file3,
|
|
289
|
-
L:
|
|
326
|
+
L: 43,
|
|
290
327
|
S: this,
|
|
291
328
|
C: (f, a) => f(...a)
|
|
292
329
|
});
|
|
@@ -298,7 +335,7 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
298
335
|
fn
|
|
299
336
|
}, {
|
|
300
337
|
F: __dxlog_file3,
|
|
301
|
-
L:
|
|
338
|
+
L: 49,
|
|
302
339
|
S: this,
|
|
303
340
|
C: (f, a) => f(...a)
|
|
304
341
|
});
|
|
@@ -309,32 +346,24 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
309
346
|
});
|
|
310
347
|
this.context.createSubscription(ast.procedureName, unsubscribe);
|
|
311
348
|
}
|
|
312
|
-
const
|
|
349
|
+
const runtime = this.context.runtime;
|
|
350
|
+
const functionDef = FunctionDefinition.deserialize(fn);
|
|
351
|
+
let input;
|
|
313
352
|
if (fn.inputSchema) {
|
|
314
353
|
const schema = toEffectSchema(fn.inputSchema);
|
|
315
|
-
SchemaAST.getPropertySignatures(schema.ast)
|
|
316
|
-
|
|
354
|
+
const props = SchemaAST.getPropertySignatures(schema.ast);
|
|
355
|
+
input = {};
|
|
356
|
+
props.forEach(({ name }, index) => {
|
|
357
|
+
input[name.toString()] = args[index];
|
|
317
358
|
});
|
|
318
359
|
} else {
|
|
319
|
-
|
|
360
|
+
input = {
|
|
361
|
+
args: args.filter(isNonNullable)
|
|
362
|
+
};
|
|
320
363
|
}
|
|
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
|
-
});
|
|
364
|
+
const result = runtime.runPromise(Effect.gen(function* () {
|
|
365
|
+
return yield* FunctionInvocationService.invokeFunction(functionDef, input);
|
|
366
|
+
}).pipe(Effect.provide(ComputeEventLogger.layerFromTracing), Effect.provide(TracingService.layerNoop)));
|
|
338
367
|
return result;
|
|
339
368
|
};
|
|
340
369
|
return this.runAsyncFunction(ast, state, handler(true), {
|
|
@@ -2775,13 +2804,26 @@ import { Event as Event2 } from "@dxos/async";
|
|
|
2775
2804
|
import { Filter as Filter2, fullyQualifiedId } from "@dxos/client/echo";
|
|
2776
2805
|
import { FQ_ID_LENGTH } from "@dxos/client/echo";
|
|
2777
2806
|
import { Resource as Resource2 } from "@dxos/context";
|
|
2778
|
-
import { getTypename } from "@dxos/echo
|
|
2807
|
+
import { getTypename } from "@dxos/echo/internal";
|
|
2779
2808
|
import { FunctionType as FunctionType2 } from "@dxos/functions";
|
|
2780
2809
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
2781
2810
|
import { PublicKey } from "@dxos/keys";
|
|
2782
2811
|
import { log as log3 } from "@dxos/log";
|
|
2783
2812
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
2784
|
-
import { ExportedCellChange as ExportedCellChange2 } from "
|
|
2813
|
+
import { ExportedCellChange as ExportedCellChange2 } from "@dxos/vendor-hyperformula";
|
|
2814
|
+
function _define_property3(obj, key, value) {
|
|
2815
|
+
if (key in obj) {
|
|
2816
|
+
Object.defineProperty(obj, key, {
|
|
2817
|
+
value,
|
|
2818
|
+
enumerable: true,
|
|
2819
|
+
configurable: true,
|
|
2820
|
+
writable: true
|
|
2821
|
+
});
|
|
2822
|
+
} else {
|
|
2823
|
+
obj[key] = value;
|
|
2824
|
+
}
|
|
2825
|
+
return obj;
|
|
2826
|
+
}
|
|
2785
2827
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/src/compute-graph.ts";
|
|
2786
2828
|
var UNKNOWN_BINDING = "__UNKNOWN__";
|
|
2787
2829
|
var createSheetName = ({ type, id }) => `${type}@${id}`;
|
|
@@ -2795,37 +2837,6 @@ var parseSheetName = (name) => {
|
|
|
2795
2837
|
};
|
|
2796
2838
|
};
|
|
2797
2839
|
var ComputeGraph = class extends Resource2 {
|
|
2798
|
-
constructor(_hf, _space, _options) {
|
|
2799
|
-
super(), this._hf = _hf, this._space = _space, this._options = _options, this.id = `graph-${PublicKey.random().truncate()}`, this._nodes = /* @__PURE__ */ new Map(), this._remoteFunctions = [], this.update = new Event2();
|
|
2800
|
-
this.context = new FunctionContext(this._hf, this._space, {
|
|
2801
|
-
...this._options,
|
|
2802
|
-
onUpdate: (update) => {
|
|
2803
|
-
this._options?.onUpdate?.(update);
|
|
2804
|
-
this.update.emit({
|
|
2805
|
-
type: "valuesUpdated"
|
|
2806
|
-
});
|
|
2807
|
-
}
|
|
2808
|
-
});
|
|
2809
|
-
this._hf.updateConfig({
|
|
2810
|
-
context: this.context
|
|
2811
|
-
});
|
|
2812
|
-
const onValuesUpdate = (changes) => {
|
|
2813
|
-
for (const change of changes) {
|
|
2814
|
-
if (change instanceof ExportedCellChange2) {
|
|
2815
|
-
const { sheet } = change;
|
|
2816
|
-
const node = this._nodes.get(sheet);
|
|
2817
|
-
if (node) {
|
|
2818
|
-
node.update.emit({
|
|
2819
|
-
type: "valuesUpdated",
|
|
2820
|
-
change
|
|
2821
|
-
});
|
|
2822
|
-
}
|
|
2823
|
-
}
|
|
2824
|
-
}
|
|
2825
|
-
};
|
|
2826
|
-
this._hf.on("valuesUpdated", onValuesUpdate);
|
|
2827
|
-
this._ctx.onDispose(() => this._hf.off("valuesUpdated", onValuesUpdate));
|
|
2828
|
-
}
|
|
2829
2840
|
get hf() {
|
|
2830
2841
|
return this._hf;
|
|
2831
2842
|
}
|
|
@@ -2853,7 +2864,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2853
2864
|
getOrCreateNode(name) {
|
|
2854
2865
|
invariant2(name.length, void 0, {
|
|
2855
2866
|
F: __dxlog_file4,
|
|
2856
|
-
L:
|
|
2867
|
+
L: 130,
|
|
2857
2868
|
S: this,
|
|
2858
2869
|
A: [
|
|
2859
2870
|
"name.length",
|
|
@@ -2866,7 +2877,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2866
2877
|
sheet: name
|
|
2867
2878
|
}, {
|
|
2868
2879
|
F: __dxlog_file4,
|
|
2869
|
-
L:
|
|
2880
|
+
L: 132,
|
|
2870
2881
|
S: this,
|
|
2871
2882
|
C: (f, a) => f(...a)
|
|
2872
2883
|
});
|
|
@@ -2875,7 +2886,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2875
2886
|
const sheetId = this._hf.getSheetId(name);
|
|
2876
2887
|
invariant2(sheetId !== void 0, void 0, {
|
|
2877
2888
|
F: __dxlog_file4,
|
|
2878
|
-
L:
|
|
2889
|
+
L: 137,
|
|
2879
2890
|
S: this,
|
|
2880
2891
|
A: [
|
|
2881
2892
|
"sheetId !== undefined",
|
|
@@ -2978,6 +2989,40 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2978
2989
|
await node.close();
|
|
2979
2990
|
}
|
|
2980
2991
|
}
|
|
2992
|
+
constructor(_hf, _runtime, _space, _options) {
|
|
2993
|
+
super(), _define_property3(this, "_hf", void 0), _define_property3(this, "_runtime", void 0), _define_property3(this, "_space", void 0), _define_property3(this, "_options", void 0), _define_property3(this, "id", void 0), // Map of nodes indexed by sheet number.
|
|
2994
|
+
_define_property3(this, "_nodes", void 0), // Cached function objects.
|
|
2995
|
+
_define_property3(this, "_remoteFunctions", void 0), _define_property3(this, "update", void 0), // The context is passed to all functions.
|
|
2996
|
+
_define_property3(this, "context", void 0), this._hf = _hf, this._runtime = _runtime, this._space = _space, this._options = _options, this.id = `graph-${PublicKey.random().truncate()}`, this._nodes = /* @__PURE__ */ new Map(), this._remoteFunctions = [], this.update = new Event2();
|
|
2997
|
+
this.context = new FunctionContext(this._hf, this._runtime, this._space, {
|
|
2998
|
+
...this._options,
|
|
2999
|
+
onUpdate: (update) => {
|
|
3000
|
+
this._options?.onUpdate?.(update);
|
|
3001
|
+
this.update.emit({
|
|
3002
|
+
type: "valuesUpdated"
|
|
3003
|
+
});
|
|
3004
|
+
}
|
|
3005
|
+
});
|
|
3006
|
+
this._hf.updateConfig({
|
|
3007
|
+
context: this.context
|
|
3008
|
+
});
|
|
3009
|
+
const onValuesUpdate = (changes) => {
|
|
3010
|
+
for (const change of changes) {
|
|
3011
|
+
if (change instanceof ExportedCellChange2) {
|
|
3012
|
+
const { sheet } = change;
|
|
3013
|
+
const node = this._nodes.get(sheet);
|
|
3014
|
+
if (node) {
|
|
3015
|
+
node.update.emit({
|
|
3016
|
+
type: "valuesUpdated",
|
|
3017
|
+
change
|
|
3018
|
+
});
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
};
|
|
3023
|
+
this._hf.on("valuesUpdated", onValuesUpdate);
|
|
3024
|
+
this._ctx.onDispose(() => this._hf.off("valuesUpdated", onValuesUpdate));
|
|
3025
|
+
}
|
|
2981
3026
|
};
|
|
2982
3027
|
|
|
2983
3028
|
// src/compute-graph-registry.ts
|
|
@@ -2985,28 +3030,31 @@ import defaultsDeep2 from "lodash.defaultsdeep";
|
|
|
2985
3030
|
import { Resource as Resource3 } from "@dxos/context";
|
|
2986
3031
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2987
3032
|
import { log as log4 } from "@dxos/log";
|
|
2988
|
-
import { HyperFormula } from "
|
|
3033
|
+
import { HyperFormula } from "@dxos/vendor-hyperformula";
|
|
3034
|
+
function _define_property4(obj, key, value) {
|
|
3035
|
+
if (key in obj) {
|
|
3036
|
+
Object.defineProperty(obj, key, {
|
|
3037
|
+
value,
|
|
3038
|
+
enumerable: true,
|
|
3039
|
+
configurable: true,
|
|
3040
|
+
writable: true
|
|
3041
|
+
});
|
|
3042
|
+
} else {
|
|
3043
|
+
obj[key] = value;
|
|
3044
|
+
}
|
|
3045
|
+
return obj;
|
|
3046
|
+
}
|
|
2989
3047
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/src/compute-graph-registry.ts";
|
|
2990
|
-
var defaultOptions = {
|
|
2991
|
-
licenseKey: "gpl-v3"
|
|
2992
|
-
};
|
|
2993
3048
|
var defaultPlugins = [
|
|
2994
3049
|
{
|
|
2995
3050
|
plugin: EdgeFunctionPlugin,
|
|
2996
3051
|
translations: EdgeFunctionPluginTranslations
|
|
2997
3052
|
}
|
|
2998
3053
|
];
|
|
3054
|
+
var defaultOptions = {
|
|
3055
|
+
licenseKey: "gpl-v3"
|
|
3056
|
+
};
|
|
2999
3057
|
var ComputeGraphRegistry = class extends Resource3 {
|
|
3000
|
-
constructor(options = {
|
|
3001
|
-
plugins: defaultPlugins
|
|
3002
|
-
}) {
|
|
3003
|
-
super();
|
|
3004
|
-
this._graphs = /* @__PURE__ */ new Map();
|
|
3005
|
-
this._options = defaultsDeep2({}, options, defaultOptions);
|
|
3006
|
-
this._options.plugins?.forEach(({ plugin, translations }) => {
|
|
3007
|
-
HyperFormula.registerFunctionPlugin(plugin, translations);
|
|
3008
|
-
});
|
|
3009
|
-
}
|
|
3010
3058
|
getGraph(spaceId) {
|
|
3011
3059
|
return this._graphs.get(spaceId);
|
|
3012
3060
|
}
|
|
@@ -3017,7 +3065,7 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3017
3065
|
space: space.id
|
|
3018
3066
|
}, {
|
|
3019
3067
|
F: __dxlog_file5,
|
|
3020
|
-
L:
|
|
3068
|
+
L: 73,
|
|
3021
3069
|
S: this,
|
|
3022
3070
|
C: (f, a) => f(...a)
|
|
3023
3071
|
});
|
|
@@ -3028,7 +3076,7 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3028
3076
|
createGraph(space) {
|
|
3029
3077
|
invariant3(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`, {
|
|
3030
3078
|
F: __dxlog_file5,
|
|
3031
|
-
L:
|
|
3079
|
+
L: 81,
|
|
3032
3080
|
S: this,
|
|
3033
3081
|
A: [
|
|
3034
3082
|
"!this._graphs.has(space.id)",
|
|
@@ -3036,7 +3084,17 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3036
3084
|
]
|
|
3037
3085
|
});
|
|
3038
3086
|
const hf = HyperFormula.buildEmpty(this._options);
|
|
3039
|
-
|
|
3087
|
+
invariant3(this._options.computeRuntime, "ComputeRuntime is required", {
|
|
3088
|
+
F: __dxlog_file5,
|
|
3089
|
+
L: 83,
|
|
3090
|
+
S: this,
|
|
3091
|
+
A: [
|
|
3092
|
+
"this._options.computeRuntime",
|
|
3093
|
+
"'ComputeRuntime is required'"
|
|
3094
|
+
]
|
|
3095
|
+
});
|
|
3096
|
+
const runtime = this._options.computeRuntime.getRuntime(space.id);
|
|
3097
|
+
const graph = new ComputeGraph(hf, runtime, space, this._options);
|
|
3040
3098
|
this._graphs.set(space.id, graph);
|
|
3041
3099
|
return graph;
|
|
3042
3100
|
}
|
|
@@ -3046,6 +3104,14 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3046
3104
|
}
|
|
3047
3105
|
this._graphs.clear();
|
|
3048
3106
|
}
|
|
3107
|
+
constructor(options) {
|
|
3108
|
+
super(), _define_property4(this, "_graphs", /* @__PURE__ */ new Map()), _define_property4(this, "_options", void 0);
|
|
3109
|
+
this._options = defaultsDeep2({}, options, defaultOptions);
|
|
3110
|
+
this._options.plugins = this._options.plugins ?? defaultPlugins;
|
|
3111
|
+
this._options.plugins?.forEach(({ plugin, translations }) => {
|
|
3112
|
+
HyperFormula.registerFunctionPlugin(plugin, translations);
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3049
3115
|
};
|
|
3050
3116
|
|
|
3051
3117
|
export {
|
|
@@ -3071,8 +3137,8 @@ export {
|
|
|
3071
3137
|
createSheetName,
|
|
3072
3138
|
parseSheetName,
|
|
3073
3139
|
ComputeGraph,
|
|
3074
|
-
defaultOptions,
|
|
3075
3140
|
defaultPlugins,
|
|
3141
|
+
defaultOptions,
|
|
3076
3142
|
ComputeGraphRegistry
|
|
3077
3143
|
};
|
|
3078
|
-
//# sourceMappingURL=chunk-
|
|
3144
|
+
//# sourceMappingURL=chunk-C7KLV2IU.mjs.map
|