@dxos/compute 0.8.4-main.5acf9ea → 0.8.4-main.5ea62a8

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.
@@ -78,10 +78,20 @@ var inRange = (range, cell) => {
78
78
  import { Event } from "@dxos/async";
79
79
  import { Resource } from "@dxos/context";
80
80
  import { DetailedCellError as DetailedCellError2 } from "#hyperformula";
81
- var ComputeNode = class extends Resource {
82
- constructor(_graph, sheetId) {
83
- super(), this._graph = _graph, this.sheetId = sheetId, this.update = new Event();
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,13 +124,29 @@ 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, ErrorType, EmptyValue, FunctionPlugin } from "#hyperformula";
136
+ import { CellError, EmptyValue, ErrorType, FunctionPlugin } from "#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,
@@ -135,25 +161,6 @@ var FunctionContext = class _FunctionContext {
135
161
  ...args
136
162
  });
137
163
  }
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
164
  get space() {
158
165
  return this._space;
159
166
  }
@@ -242,6 +249,33 @@ var FunctionContext = class _FunctionContext {
242
249
  });
243
250
  return value;
244
251
  }
252
+ constructor(_hf, _space, _options) {
253
+ _define_property2(this, "_hf", 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._space = _space;
263
+ this._cache = /* @__PURE__ */ new Map();
264
+ this._pending = /* @__PURE__ */ new Map();
265
+ this._subscriptions = /* @__PURE__ */ new Map();
266
+ this._invocations = {};
267
+ this._options = defaultsDeep(_options ?? {}, defaultFunctionContextOptions);
268
+ this._onUpdate = debounce((update) => {
269
+ log("update", update, {
270
+ F: __dxlog_file2,
271
+ L: 86,
272
+ S: this,
273
+ C: (f, a) => f(...a)
274
+ });
275
+ this._hf.resumeEvaluation();
276
+ this._options.onUpdate?.(update);
277
+ }, this._options.debounceDelay);
278
+ }
245
279
  };
246
280
  var AsyncFunctionPlugin = class extends FunctionPlugin {
247
281
  get context() {
@@ -264,7 +298,7 @@ import { effect } from "@preact/signals-core";
264
298
  import { SchemaAST } from "effect";
265
299
  import { Filter, getMeta } from "@dxos/client/echo";
266
300
  import { toEffectSchema } from "@dxos/echo-schema";
267
- import { FunctionType, getUserFunctionUrlInMetadata } from "@dxos/functions";
301
+ import { FunctionType, getUserFunctionIdInMetadata } from "@dxos/functions";
268
302
  import { log as log2 } from "@dxos/log";
269
303
  import { isNonNullable } from "@dxos/util";
270
304
  import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "#hyperformula";
@@ -318,8 +352,8 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
318
352
  } else {
319
353
  body.args = args.filter(isNonNullable);
320
354
  }
321
- const path = getUserFunctionUrlInMetadata(getMeta(fn));
322
- const response = await fetch(`${this.context.remoteFunctionUrl}${path}`, {
355
+ const id = getUserFunctionIdInMetadata(getMeta(fn));
356
+ const response = await fetch(`${this.context.remoteFunctionUrl}/${id}`, {
323
357
  method: "POST",
324
358
  headers: {
325
359
  "Content-Type": "application/json"
@@ -2782,6 +2816,19 @@ import { PublicKey } from "@dxos/keys";
2782
2816
  import { log as log3 } from "@dxos/log";
2783
2817
  import { isNonNullable as isNonNullable2 } from "@dxos/util";
2784
2818
  import { ExportedCellChange as ExportedCellChange2 } from "#hyperformula";
2819
+ function _define_property3(obj, key, value) {
2820
+ if (key in obj) {
2821
+ Object.defineProperty(obj, key, {
2822
+ value,
2823
+ enumerable: true,
2824
+ configurable: true,
2825
+ writable: true
2826
+ });
2827
+ } else {
2828
+ obj[key] = value;
2829
+ }
2830
+ return obj;
2831
+ }
2785
2832
  var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/src/compute-graph.ts";
2786
2833
  var UNKNOWN_BINDING = "__UNKNOWN__";
2787
2834
  var createSheetName = ({ type, id }) => `${type}@${id}`;
@@ -2795,37 +2842,6 @@ var parseSheetName = (name) => {
2795
2842
  };
2796
2843
  };
2797
2844
  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
2845
  get hf() {
2830
2846
  return this._hf;
2831
2847
  }
@@ -2978,6 +2994,40 @@ var ComputeGraph = class extends Resource2 {
2978
2994
  await node.close();
2979
2995
  }
2980
2996
  }
2997
+ constructor(_hf, _space, _options) {
2998
+ 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.
2999
+ _define_property3(this, "_nodes", void 0), // Cached function objects.
3000
+ _define_property3(this, "_remoteFunctions", void 0), _define_property3(this, "update", void 0), // The context is passed to all functions.
3001
+ _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();
3002
+ this.context = new FunctionContext(this._hf, this._space, {
3003
+ ...this._options,
3004
+ onUpdate: (update) => {
3005
+ this._options?.onUpdate?.(update);
3006
+ this.update.emit({
3007
+ type: "valuesUpdated"
3008
+ });
3009
+ }
3010
+ });
3011
+ this._hf.updateConfig({
3012
+ context: this.context
3013
+ });
3014
+ const onValuesUpdate = (changes) => {
3015
+ for (const change of changes) {
3016
+ if (change instanceof ExportedCellChange2) {
3017
+ const { sheet } = change;
3018
+ const node = this._nodes.get(sheet);
3019
+ if (node) {
3020
+ node.update.emit({
3021
+ type: "valuesUpdated",
3022
+ change
3023
+ });
3024
+ }
3025
+ }
3026
+ }
3027
+ };
3028
+ this._hf.on("valuesUpdated", onValuesUpdate);
3029
+ this._ctx.onDispose(() => this._hf.off("valuesUpdated", onValuesUpdate));
3030
+ }
2981
3031
  };
2982
3032
 
2983
3033
  // src/compute-graph-registry.ts
@@ -2986,6 +3036,19 @@ import { Resource as Resource3 } from "@dxos/context";
2986
3036
  import { invariant as invariant3 } from "@dxos/invariant";
2987
3037
  import { log as log4 } from "@dxos/log";
2988
3038
  import { HyperFormula } from "#hyperformula";
3039
+ function _define_property4(obj, key, value) {
3040
+ if (key in obj) {
3041
+ Object.defineProperty(obj, key, {
3042
+ value,
3043
+ enumerable: true,
3044
+ configurable: true,
3045
+ writable: true
3046
+ });
3047
+ } else {
3048
+ obj[key] = value;
3049
+ }
3050
+ return obj;
3051
+ }
2989
3052
  var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/src/compute-graph-registry.ts";
2990
3053
  var defaultOptions = {
2991
3054
  licenseKey: "gpl-v3"
@@ -2997,16 +3060,6 @@ var defaultPlugins = [
2997
3060
  }
2998
3061
  ];
2999
3062
  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
3063
  getGraph(spaceId) {
3011
3064
  return this._graphs.get(spaceId);
3012
3065
  }
@@ -3046,6 +3099,15 @@ var ComputeGraphRegistry = class extends Resource3 {
3046
3099
  }
3047
3100
  this._graphs.clear();
3048
3101
  }
3102
+ constructor(options = {
3103
+ plugins: defaultPlugins
3104
+ }) {
3105
+ super(), _define_property4(this, "_graphs", /* @__PURE__ */ new Map()), _define_property4(this, "_options", void 0);
3106
+ this._options = defaultsDeep2({}, options, defaultOptions);
3107
+ this._options.plugins?.forEach(({ plugin, translations }) => {
3108
+ HyperFormula.registerFunctionPlugin(plugin, translations);
3109
+ });
3110
+ }
3049
3111
  };
3050
3112
 
3051
3113
  export {
@@ -3075,4 +3137,4 @@ export {
3075
3137
  defaultPlugins,
3076
3138
  ComputeGraphRegistry
3077
3139
  };
3078
- //# sourceMappingURL=chunk-AURNYRCC.mjs.map
3140
+ //# sourceMappingURL=chunk-OFPP3ZEX.mjs.map