@dxos/compute 0.8.4-main.e098934 → 0.8.4-main.ead640a
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-XQYPCRZP.mjs → chunk-C7KLV2IU.mjs} +60 -56
- 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 +24 -4
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/{chunk-2XWWSGAU.mjs → chunk-K37OSZ5O.mjs} +60 -56
- 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 +24 -4
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/compute-graph-registry.d.ts +8 -3
- 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 +4 -1
- package/dist/types/src/compute-graph.d.ts.map +1 -1
- package/dist/types/src/functions/async-function.d.ts +11 -9
- package/dist/types/src/functions/async-function.d.ts.map +1 -1
- 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-runtime.d.ts +10 -0
- package/dist/types/src/testing/test-runtime.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -22
- package/src/compute-graph-registry.test.ts +138 -0
- package/src/compute-graph-registry.ts +17 -8
- package/src/compute-graph.ts +7 -4
- package/src/functions/async-function.ts +13 -12
- package/src/functions/edge-function.ts +21 -18
- package/src/testing/index.ts +1 -0
- package/src/testing/test-builder.ts +8 -2
- package/src/testing/test-runtime.ts +38 -0
- package/dist/lib/browser/chunk-XQYPCRZP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2XWWSGAU.mjs.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/testing/test-builder.ts", "../../../../src/testing/test-plugin.ts", "../../../../src/util.ts", "../../../../src/testing/util.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Client, type ClientOptions } from '@dxos/client';\nimport { type Context, Resource } from '@dxos/context';\nimport { invariant } from '@dxos/invariant';\n\nimport { type ComputeGraphOptions, ComputeGraphRegistry } from '../compute-graph-registry';\n\nexport type TestBuilderOptions = ClientOptions & ComputeGraphOptions
|
|
5
|
-
"mappings": ";;;;;;AAIA,SAASA,cAAkC;AAC3C,SAAuBC,gBAAgB;AACvC,SAASC,iBAAiB
|
|
6
|
-
"names": ["Client", "Resource", "invariant", "TestBuilder", "Resource", "ctx", "_ctx", "client", "invariant", "_client", "registry", "_registry", "_open", "Client", "_options", "initialize", "halo", "createIdentity", "onDispose", "destroy", "undefined", "ComputeGraphRegistry", "open", "close", "getDeep", "FunctionArgumentType", "parseNumberString", "str", "parseFloat", "replace", "TestPlugin", "AsyncFunctionPlugin", "test", "ast", "state", "handler", "_value", "runAsyncFunction", "random", "Math", "crypto", "_currency", "currency", "toUpperCase", "result", "fetch", "data", "json", "rate", "getDeep", "NaN", "parseNumberString", "ttl", "implementedFunctions", "TEST", "method", "parameters", "argumentType", "FunctionArgumentType", "NUMBER", "optionalArg", "isVolatile", "RANDOM", "CRYPTO", "STRING", "TestPluginTranslations", "enGB", "enUS", "testFunctionPlugins", "plugin", "translations", "HyperFormula", "getRegisteredFunctionNames", "HyperFormula", "buildEmpty", "licenseKey"]
|
|
3
|
+
"sources": ["../../../../src/testing/test-builder.ts", "../../../../src/testing/test-runtime.ts", "../../../../src/testing/test-plugin.ts", "../../../../src/util.ts", "../../../../src/testing/util.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Client, type ClientOptions } from '@dxos/client';\nimport { type Context, Resource } from '@dxos/context';\nimport { invariant } from '@dxos/invariant';\n\nimport { type ComputeGraphOptions, ComputeGraphRegistry } from '../compute-graph-registry';\n\nimport { createMockedComputeRuntimeProvider } from './test-runtime';\n\nexport type TestBuilderOptions = ClientOptions & Partial<ComputeGraphOptions>;\n\n// TODO(burdon): Reconcile with @dxos/client/testing.\nexport class TestBuilder extends Resource {\n private _client?: Client;\n private _registry?: ComputeGraphRegistry;\n\n constructor(private readonly _options: TestBuilderOptions = {}) {\n super();\n }\n\n get ctx(): Context {\n return this._ctx;\n }\n\n get client(): Client {\n invariant(this._client);\n return this._client;\n }\n\n get registry(): ComputeGraphRegistry {\n invariant(this._registry);\n return this._registry;\n }\n\n override async _open(): Promise<void> {\n const client = new Client(this._options);\n await client.initialize();\n await client.halo.createIdentity();\n this._client = client;\n this._ctx.onDispose(async () => {\n await client.destroy();\n this._client = undefined;\n });\n\n const registry = new ComputeGraphRegistry({\n ...this._options,\n // Provide a default runtime provider for tests if not supplied.\n computeRuntime: this._options.computeRuntime ?? createMockedComputeRuntimeProvider(),\n });\n await registry.open();\n this._registry = registry;\n this._ctx.onDispose(async () => {\n await registry.close();\n this._registry = undefined;\n });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport { AiService } from '@dxos/ai';\nimport { type SpaceId } from '@dxos/client/echo';\nimport {\n CredentialsService,\n DatabaseService,\n type FunctionDefinition,\n FunctionInvocationService,\n QueueService,\n} from '@dxos/functions';\n\nimport { type FunctionsRuntimeProvider } from '../compute-graph-registry';\n\n/**\n * Minimal compute runtime provider for tests and Storybook.\n * Will cause errors if used for actual runtime.\n */\nexport const createMockedComputeRuntimeProvider = ({\n functions,\n}: { functions?: FunctionDefinition<any, any>[] } = {}): FunctionsRuntimeProvider => {\n return {\n getRuntime: (_spaceId: SpaceId) =>\n ManagedRuntime.make(\n FunctionInvocationService.layerTest({ functions }).pipe(\n Layer.provide(AiService.notAvailable),\n Layer.provide(CredentialsService.configuredLayer([])),\n Layer.provide(DatabaseService.notAvailable),\n Layer.provide(QueueService.notAvailable),\n ),\n ),\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { getDeep } from '@dxos/util';\nimport { type InterpreterState, type ProcedureAst } from '@dxos/vendor-hyperformula';\nimport { FunctionArgumentType } from '@dxos/vendor-hyperformula';\n\nimport { type ComputeGraphPlugin } from '../compute-graph-registry';\nimport { type AsyncFunction, AsyncFunctionPlugin } from '../functions';\nimport { parseNumberString } from '../util';\n\n/**\n * Testing functions run locally (not run via EDGE).\n * https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function\n */\nexport class TestPlugin extends AsyncFunctionPlugin {\n /**\n * Simple local function returns input value.\n */\n test(ast: ProcedureAst, state: InterpreterState) {\n const handler: AsyncFunction = async (_value) => {\n return _value;\n };\n\n return this.runAsyncFunction(ast, state, handler);\n }\n\n /**\n * Simple local function returns random number.\n */\n random(ast: ProcedureAst, state: InterpreterState) {\n const handler: AsyncFunction = async () => {\n return Math.random();\n };\n\n return this.runAsyncFunction(ast, state, handler);\n }\n\n /**\n * Async HTTP function.\n */\n crypto(ast: ProcedureAst, state: InterpreterState) {\n const handler: AsyncFunction = async (_currency) => {\n const currency = (_currency || 'USD').toUpperCase();\n const result = await fetch(`https://api.coindesk.com/v1/bpi/currentprice/${currency}.json`);\n const data = await result.json();\n const rate = getDeep<string>(data, ['bpi', currency, 'rate']);\n if (!rate) {\n return NaN;\n }\n\n return parseNumberString(rate);\n };\n\n return this.runAsyncFunction(ast, state, handler, { ttl: 10_000 });\n }\n}\n\nTestPlugin.implementedFunctions = {\n TEST: {\n method: 'test',\n parameters: [{ argumentType: FunctionArgumentType.NUMBER, optionalArg: false }],\n isVolatile: true,\n },\n\n RANDOM: {\n method: 'random',\n parameters: [],\n isVolatile: true,\n },\n\n CRYPTO: {\n method: 'crypto',\n parameters: [{ argumentType: FunctionArgumentType.STRING, optionalArg: true }],\n isVolatile: true,\n },\n};\n\nexport const TestPluginTranslations = {\n enGB: {\n TEST: 'Returns input value',\n RANDOM: 'Random number',\n CRYPTO: 'Crypto token value',\n },\n enUS: {\n TEST: 'Returns input value',\n RANDOM: 'Random number',\n CRYPTO: 'Crypto token value',\n },\n};\n\nexport const testFunctionPlugins: ComputeGraphPlugin[] = [\n {\n plugin: TestPlugin,\n translations: TestPluginTranslations,\n },\n];\n", "//\n// Copyright 2024 DXOS.org\n//\n\n// TODO(burdon): Factor out.\nexport const parseNumberString = (str: string): number => {\n return parseFloat(str.replace(/[^\\d.]/g, ''));\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { HyperFormula } from '@dxos/vendor-hyperformula';\n\nexport const getRegisteredFunctionNames = () => {\n return HyperFormula.buildEmpty({ licenseKey: 'gpl-v3' }).getRegisteredFunctionNames();\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,SAASA,cAAkC;AAC3C,SAAuBC,gBAAgB;AACvC,SAASC,iBAAiB;;;ACF1B,YAAYC,WAAW;AACvB,YAAYC,oBAAoB;AAEhC,SAASC,iBAAiB;AAE1B,SACEC,oBACAC,iBAEAC,2BACAC,oBACK;AAQA,IAAMC,qCAAqC,CAAC,EACjDC,UAAS,IACyC,CAAC,MAAC;AACpD,SAAO;IACLC,YAAY,CAACC,aACIC,oBACbC,0BAA0BC,UAAU;MAAEL;IAAU,CAAA,EAAGM,KAC3CC,cAAQC,UAAUC,YAAY,GAC9BF,cAAQG,mBAAmBC,gBAAgB,CAAA,CAAE,CAAA,GAC7CJ,cAAQK,gBAAg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B;AAEtB,IAAMC,6BAA6B,MAAA;AACxC,SAAOC,aAAaC,WAAW;IAAEC,YAAY;EAAS,CAAA,EAAGH,2BAA0B;AACrF;",
|
|
6
|
+
"names": ["Client", "Resource", "invariant", "Layer", "ManagedRuntime", "AiService", "CredentialsService", "DatabaseService", "FunctionInvocationService", "QueueService", "createMockedComputeRuntimeProvider", "functions", "getRuntime", "_spaceId", "make", "FunctionInvocationService", "layerTest", "pipe", "provide", "AiService", "notAvailable", "CredentialsService", "configuredLayer", "DatabaseService", "QueueService", "TestBuilder", "Resource", "ctx", "_ctx", "client", "invariant", "_client", "registry", "_registry", "_open", "Client", "_options", "initialize", "halo", "createIdentity", "onDispose", "destroy", "undefined", "ComputeGraphRegistry", "computeRuntime", "createMockedComputeRuntimeProvider", "open", "close", "getDeep", "FunctionArgumentType", "parseNumberString", "str", "parseFloat", "replace", "TestPlugin", "AsyncFunctionPlugin", "test", "ast", "state", "handler", "_value", "runAsyncFunction", "random", "Math", "crypto", "_currency", "currency", "toUpperCase", "result", "fetch", "data", "json", "rate", "getDeep", "NaN", "parseNumberString", "ttl", "implementedFunctions", "TEST", "method", "parameters", "argumentType", "FunctionArgumentType", "NUMBER", "optionalArg", "isVolatile", "RANDOM", "CRYPTO", "STRING", "TestPluginTranslations", "enGB", "enUS", "testFunctionPlugins", "plugin", "translations", "HyperFormula", "getRegisteredFunctionNames", "HyperFormula", "buildEmpty", "licenseKey"]
|
|
7
7
|
}
|
|
@@ -152,8 +152,7 @@ function _define_property2(obj, key, value) {
|
|
|
152
152
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/src/functions/async-function.ts";
|
|
153
153
|
var defaultFunctionContextOptions = {
|
|
154
154
|
defaultTtl: 5e3,
|
|
155
|
-
debounceDelay: 200
|
|
156
|
-
remoteFunctionUrl: "https://edge.dxos.workers.dev/functions"
|
|
155
|
+
debounceDelay: 200
|
|
157
156
|
};
|
|
158
157
|
var FunctionContext = class _FunctionContext {
|
|
159
158
|
// Mangle name with params.
|
|
@@ -166,15 +165,15 @@ var FunctionContext = class _FunctionContext {
|
|
|
166
165
|
get space() {
|
|
167
166
|
return this._space;
|
|
168
167
|
}
|
|
169
|
-
get remoteFunctionUrl() {
|
|
170
|
-
return this._options.remoteFunctionUrl;
|
|
171
|
-
}
|
|
172
168
|
get info() {
|
|
173
169
|
return {
|
|
174
170
|
cache: this._cache.size,
|
|
175
171
|
invocations: this._invocations
|
|
176
172
|
};
|
|
177
173
|
}
|
|
174
|
+
get runtime() {
|
|
175
|
+
return this._runtime;
|
|
176
|
+
}
|
|
178
177
|
flush() {
|
|
179
178
|
this._cache.clear();
|
|
180
179
|
this._invocations = {};
|
|
@@ -211,7 +210,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
211
210
|
value: value2
|
|
212
211
|
}, {
|
|
213
212
|
F: __dxlog_file2,
|
|
214
|
-
L:
|
|
213
|
+
L: 144,
|
|
215
214
|
S: this,
|
|
216
215
|
C: (f, a) => f(...a)
|
|
217
216
|
});
|
|
@@ -225,7 +224,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
225
224
|
err
|
|
226
225
|
}, {
|
|
227
226
|
F: __dxlog_file2,
|
|
228
|
-
L:
|
|
227
|
+
L: 148,
|
|
229
228
|
S: this,
|
|
230
229
|
C: (f, a) => f(...a)
|
|
231
230
|
});
|
|
@@ -245,14 +244,15 @@ var FunctionContext = class _FunctionContext {
|
|
|
245
244
|
cache: value
|
|
246
245
|
}, {
|
|
247
246
|
F: __dxlog_file2,
|
|
248
|
-
L:
|
|
247
|
+
L: 156,
|
|
249
248
|
S: this,
|
|
250
249
|
C: (f, a) => f(...a)
|
|
251
250
|
});
|
|
252
251
|
return value;
|
|
253
252
|
}
|
|
254
|
-
constructor(_hf, _space, _options) {
|
|
253
|
+
constructor(_hf, _runtime, _space, _options) {
|
|
255
254
|
_define_property2(this, "_hf", void 0);
|
|
255
|
+
_define_property2(this, "_runtime", void 0);
|
|
256
256
|
_define_property2(this, "_space", void 0);
|
|
257
257
|
_define_property2(this, "_cache", void 0);
|
|
258
258
|
_define_property2(this, "_pending", void 0);
|
|
@@ -261,6 +261,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
261
261
|
_define_property2(this, "_options", void 0);
|
|
262
262
|
_define_property2(this, "_onUpdate", void 0);
|
|
263
263
|
this._hf = _hf;
|
|
264
|
+
this._runtime = _runtime;
|
|
264
265
|
this._space = _space;
|
|
265
266
|
this._cache = /* @__PURE__ */ new Map();
|
|
266
267
|
this._pending = /* @__PURE__ */ new Map();
|
|
@@ -270,7 +271,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
270
271
|
this._onUpdate = debounce((update) => {
|
|
271
272
|
log("update", update, {
|
|
272
273
|
F: __dxlog_file2,
|
|
273
|
-
L:
|
|
274
|
+
L: 86,
|
|
274
275
|
S: this,
|
|
275
276
|
C: (f, a) => f(...a)
|
|
276
277
|
});
|
|
@@ -297,10 +298,12 @@ var AsyncFunctionPlugin = class extends FunctionPlugin {
|
|
|
297
298
|
|
|
298
299
|
// src/functions/edge-function.ts
|
|
299
300
|
import { effect } from "@preact/signals-core";
|
|
300
|
-
import
|
|
301
|
-
import
|
|
302
|
-
import {
|
|
303
|
-
import {
|
|
301
|
+
import * as Effect from "effect/Effect";
|
|
302
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
303
|
+
import { Filter } from "@dxos/client/echo";
|
|
304
|
+
import { toEffectSchema } from "@dxos/echo/internal";
|
|
305
|
+
import { ComputeEventLogger, FunctionInvocationService, FunctionType, TracingService } from "@dxos/functions";
|
|
306
|
+
import { FunctionDefinition } from "@dxos/functions";
|
|
304
307
|
import { log as log2 } from "@dxos/log";
|
|
305
308
|
import { isNonNullable } from "@dxos/util";
|
|
306
309
|
import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "@dxos/vendor-hyperformula";
|
|
@@ -322,7 +325,7 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
322
325
|
binding
|
|
323
326
|
}, {
|
|
324
327
|
F: __dxlog_file3,
|
|
325
|
-
L:
|
|
328
|
+
L: 43,
|
|
326
329
|
S: this,
|
|
327
330
|
C: (f, a) => f(...a)
|
|
328
331
|
});
|
|
@@ -334,7 +337,7 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
334
337
|
fn
|
|
335
338
|
}, {
|
|
336
339
|
F: __dxlog_file3,
|
|
337
|
-
L:
|
|
340
|
+
L: 49,
|
|
338
341
|
S: this,
|
|
339
342
|
C: (f, a) => f(...a)
|
|
340
343
|
});
|
|
@@ -345,32 +348,24 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
345
348
|
});
|
|
346
349
|
this.context.createSubscription(ast.procedureName, unsubscribe);
|
|
347
350
|
}
|
|
348
|
-
const
|
|
351
|
+
const runtime = this.context.runtime;
|
|
352
|
+
const functionDef = FunctionDefinition.deserialize(fn);
|
|
353
|
+
let input;
|
|
349
354
|
if (fn.inputSchema) {
|
|
350
355
|
const schema = toEffectSchema(fn.inputSchema);
|
|
351
|
-
SchemaAST.getPropertySignatures(schema.ast)
|
|
352
|
-
|
|
356
|
+
const props = SchemaAST.getPropertySignatures(schema.ast);
|
|
357
|
+
input = {};
|
|
358
|
+
props.forEach(({ name }, index) => {
|
|
359
|
+
input[name.toString()] = args[index];
|
|
353
360
|
});
|
|
354
361
|
} else {
|
|
355
|
-
|
|
362
|
+
input = {
|
|
363
|
+
args: args.filter(isNonNullable)
|
|
364
|
+
};
|
|
356
365
|
}
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
headers: {
|
|
361
|
-
"Content-Type": "application/json"
|
|
362
|
-
},
|
|
363
|
-
body: JSON.stringify(body)
|
|
364
|
-
});
|
|
365
|
-
const result = await response.text();
|
|
366
|
-
log2("function executed", {
|
|
367
|
-
result
|
|
368
|
-
}, {
|
|
369
|
-
F: __dxlog_file3,
|
|
370
|
-
L: 74,
|
|
371
|
-
S: this,
|
|
372
|
-
C: (f, a) => f(...a)
|
|
373
|
-
});
|
|
366
|
+
const result = runtime.runPromise(Effect.gen(function* () {
|
|
367
|
+
return yield* FunctionInvocationService.invokeFunction(functionDef, input);
|
|
368
|
+
}).pipe(Effect.provide(ComputeEventLogger.layerFromTracing), Effect.provide(TracingService.layerNoop)));
|
|
374
369
|
return result;
|
|
375
370
|
};
|
|
376
371
|
return this.runAsyncFunction(ast, state, handler(true), {
|
|
@@ -2811,7 +2806,7 @@ import { Event as Event2 } from "@dxos/async";
|
|
|
2811
2806
|
import { Filter as Filter2, fullyQualifiedId } from "@dxos/client/echo";
|
|
2812
2807
|
import { FQ_ID_LENGTH } from "@dxos/client/echo";
|
|
2813
2808
|
import { Resource as Resource2 } from "@dxos/context";
|
|
2814
|
-
import { getTypename } from "@dxos/echo
|
|
2809
|
+
import { getTypename } from "@dxos/echo/internal";
|
|
2815
2810
|
import { FunctionType as FunctionType2 } from "@dxos/functions";
|
|
2816
2811
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
2817
2812
|
import { PublicKey } from "@dxos/keys";
|
|
@@ -2871,7 +2866,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2871
2866
|
getOrCreateNode(name) {
|
|
2872
2867
|
invariant2(name.length, void 0, {
|
|
2873
2868
|
F: __dxlog_file4,
|
|
2874
|
-
L:
|
|
2869
|
+
L: 130,
|
|
2875
2870
|
S: this,
|
|
2876
2871
|
A: [
|
|
2877
2872
|
"name.length",
|
|
@@ -2884,7 +2879,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2884
2879
|
sheet: name
|
|
2885
2880
|
}, {
|
|
2886
2881
|
F: __dxlog_file4,
|
|
2887
|
-
L:
|
|
2882
|
+
L: 132,
|
|
2888
2883
|
S: this,
|
|
2889
2884
|
C: (f, a) => f(...a)
|
|
2890
2885
|
});
|
|
@@ -2893,7 +2888,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2893
2888
|
const sheetId = this._hf.getSheetId(name);
|
|
2894
2889
|
invariant2(sheetId !== void 0, void 0, {
|
|
2895
2890
|
F: __dxlog_file4,
|
|
2896
|
-
L:
|
|
2891
|
+
L: 137,
|
|
2897
2892
|
S: this,
|
|
2898
2893
|
A: [
|
|
2899
2894
|
"sheetId !== undefined",
|
|
@@ -2996,12 +2991,12 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2996
2991
|
await node.close();
|
|
2997
2992
|
}
|
|
2998
2993
|
}
|
|
2999
|
-
constructor(_hf, _space, _options) {
|
|
3000
|
-
super(), _define_property3(this, "_hf", 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
|
+
constructor(_hf, _runtime, _space, _options) {
|
|
2995
|
+
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.
|
|
3001
2996
|
_define_property3(this, "_nodes", void 0), // Cached function objects.
|
|
3002
2997
|
_define_property3(this, "_remoteFunctions", void 0), _define_property3(this, "update", void 0), // The context is passed to all functions.
|
|
3003
|
-
_define_property3(this, "context", void 0), 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();
|
|
3004
|
-
this.context = new FunctionContext(this._hf, this._space, {
|
|
2998
|
+
_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();
|
|
2999
|
+
this.context = new FunctionContext(this._hf, this._runtime, this._space, {
|
|
3005
3000
|
...this._options,
|
|
3006
3001
|
onUpdate: (update) => {
|
|
3007
3002
|
this._options?.onUpdate?.(update);
|
|
@@ -3052,15 +3047,15 @@ function _define_property4(obj, key, value) {
|
|
|
3052
3047
|
return obj;
|
|
3053
3048
|
}
|
|
3054
3049
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/src/compute-graph-registry.ts";
|
|
3055
|
-
var defaultOptions = {
|
|
3056
|
-
licenseKey: "gpl-v3"
|
|
3057
|
-
};
|
|
3058
3050
|
var defaultPlugins = [
|
|
3059
3051
|
{
|
|
3060
3052
|
plugin: EdgeFunctionPlugin,
|
|
3061
3053
|
translations: EdgeFunctionPluginTranslations
|
|
3062
3054
|
}
|
|
3063
3055
|
];
|
|
3056
|
+
var defaultOptions = {
|
|
3057
|
+
licenseKey: "gpl-v3"
|
|
3058
|
+
};
|
|
3064
3059
|
var ComputeGraphRegistry = class extends Resource3 {
|
|
3065
3060
|
getGraph(spaceId) {
|
|
3066
3061
|
return this._graphs.get(spaceId);
|
|
@@ -3072,7 +3067,7 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3072
3067
|
space: space.id
|
|
3073
3068
|
}, {
|
|
3074
3069
|
F: __dxlog_file5,
|
|
3075
|
-
L:
|
|
3070
|
+
L: 73,
|
|
3076
3071
|
S: this,
|
|
3077
3072
|
C: (f, a) => f(...a)
|
|
3078
3073
|
});
|
|
@@ -3083,7 +3078,7 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3083
3078
|
createGraph(space) {
|
|
3084
3079
|
invariant3(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`, {
|
|
3085
3080
|
F: __dxlog_file5,
|
|
3086
|
-
L:
|
|
3081
|
+
L: 81,
|
|
3087
3082
|
S: this,
|
|
3088
3083
|
A: [
|
|
3089
3084
|
"!this._graphs.has(space.id)",
|
|
@@ -3091,7 +3086,17 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3091
3086
|
]
|
|
3092
3087
|
});
|
|
3093
3088
|
const hf = HyperFormula.buildEmpty(this._options);
|
|
3094
|
-
|
|
3089
|
+
invariant3(this._options.computeRuntime, "ComputeRuntime is required", {
|
|
3090
|
+
F: __dxlog_file5,
|
|
3091
|
+
L: 83,
|
|
3092
|
+
S: this,
|
|
3093
|
+
A: [
|
|
3094
|
+
"this._options.computeRuntime",
|
|
3095
|
+
"'ComputeRuntime is required'"
|
|
3096
|
+
]
|
|
3097
|
+
});
|
|
3098
|
+
const runtime = this._options.computeRuntime.getRuntime(space.id);
|
|
3099
|
+
const graph = new ComputeGraph(hf, runtime, space, this._options);
|
|
3095
3100
|
this._graphs.set(space.id, graph);
|
|
3096
3101
|
return graph;
|
|
3097
3102
|
}
|
|
@@ -3101,11 +3106,10 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
3101
3106
|
}
|
|
3102
3107
|
this._graphs.clear();
|
|
3103
3108
|
}
|
|
3104
|
-
constructor(options
|
|
3105
|
-
plugins: defaultPlugins
|
|
3106
|
-
}) {
|
|
3109
|
+
constructor(options) {
|
|
3107
3110
|
super(), _define_property4(this, "_graphs", /* @__PURE__ */ new Map()), _define_property4(this, "_options", void 0);
|
|
3108
3111
|
this._options = defaultsDeep2({}, options, defaultOptions);
|
|
3112
|
+
this._options.plugins = this._options.plugins ?? defaultPlugins;
|
|
3109
3113
|
this._options.plugins?.forEach(({ plugin, translations }) => {
|
|
3110
3114
|
HyperFormula.registerFunctionPlugin(plugin, translations);
|
|
3111
3115
|
});
|
|
@@ -3135,8 +3139,8 @@ export {
|
|
|
3135
3139
|
createSheetName,
|
|
3136
3140
|
parseSheetName,
|
|
3137
3141
|
ComputeGraph,
|
|
3138
|
-
defaultOptions,
|
|
3139
3142
|
defaultPlugins,
|
|
3143
|
+
defaultOptions,
|
|
3140
3144
|
ComputeGraphRegistry
|
|
3141
3145
|
};
|
|
3142
|
-
//# sourceMappingURL=chunk-
|
|
3146
|
+
//# sourceMappingURL=chunk-K37OSZ5O.mjs.map
|