foldkit-surface 0.10.2 → 0.12.0
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/README.md +107 -16
- package/dist/diagnostics.d.ts +63 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +104 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/{index.d.mts → index.d.ts} +121 -43
- package/dist/index.d.ts.map +1 -0
- package/dist/{index.mjs → index.js} +163 -92
- package/dist/index.js.map +1 -0
- package/package.json +9 -9
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["Metadata","MetadataSummary","ManagedResourceEntry"],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;qBAkCa;;iBAGI,MAAM,MAAM,OAAO;;WAEzB,QAAQ,OAAO,MAAM,OAAO;WAC5B,OAAO,MAAM,SAAS,MAAM;;WAE5B;WACA,MAAM,MAAM,SAAS;WACrB,MAAM,MAAM,MAAM,OAAO,UAAU;;;;;;;WAOnC,SAAS,MAAM,MAAM,KAAK,OAAO,UAAU,UAAU;;;;;;iBAO/C,SAAS,MAAM,OAAO;YAC3B,YAAY,MAAM,MAAM,OAAO;;;;;;;iBAQ1B,SACf,MACA,OACA,6BACA,2BACQ,SAAS,MAAM,OAAO;YACpB,YAAY,MAAM,MAAM,OAAO;aAC9B,KAAK;;aAEL;;;qBAmBA;;;;;EAKX,YAAY,MAAM,OAAK,QACb,OAAO,OAAO,QAAM,OACrB,MAAM,SAAS,MAAM,QAAM,mCAEjC,SAAS,MAAM;;;;;;EAclB,QAAQ;cAAsB;KAAoB,KAAO,MAAI,SAAS;;EAGtE,KAAE,mBAAoB,SAAS;;YAIrB,QAAQ,MAAM,UAAU,OAAO,OAAO,sBACtC,WAAW,aAAa,QAAQ,MAAM,EAAE,IAAI;;iBAIvC,QAAQ,MAAM;YACnB;aAC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C;EACX,OAAO,MAAM,UAAU,OAAO,OAAO,QAAQ,cAAc,eAAe,OAAO,OAAO,SAAO,KACxF,SAAS,MAAM,GAAG,QAAM,iBACb,WAAW,YAC1B,OAAO,MAAM,GAAG;;EAGnB,MAAM,MAAM,UAAU,OAAO,OAAO,QAAQ,cAAc,eAAe,OAAO,OAAO,SAAO,QACpF,OAAO,MAAM,GAAG,WAAM,gBACX,WAAW,YAC7B,OAAO,MAAM,GAAG;;;;;;;EAWnB,WAAQ,QAAW,mCAAiC;;;;;;EA8EpD,WAAQ,QAAW,0BAAwB;;EA0B3C,aAAU,QAAW;;;;;EAgCrB,YAAS,QAAW"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Optic, Option, Predicate, Result, Schema } from "effect";
|
|
2
2
|
import { Metadata, Metadata as Metadata$1, MetadataTypeId } from "foldkit-metadata";
|
|
3
|
-
|
|
3
|
+
import { Diagnostics } from "./diagnostics.js";
|
|
4
|
+
// src/index.ts
|
|
4
5
|
/**
|
|
5
6
|
* `foldkit-surface` — the observation boundary for a Foldkit application.
|
|
6
7
|
*
|
|
@@ -14,39 +15,37 @@ import { Metadata, Metadata as Metadata$1, MetadataTypeId } from "foldkit-metada
|
|
|
14
15
|
* `test/inference.test-d.ts`.
|
|
15
16
|
*/
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
18
|
+
* The key a ref keeps its own members under; read them with `ModelRef.focus`.
|
|
19
|
+
* A ref's string keys are the Model's fields, whatever their names (#331),
|
|
20
|
+
* and no Schema field reaches a symbol. `Symbol.for`, so two copies of this
|
|
21
|
+
* package read each other's refs.
|
|
19
22
|
*/
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
"at",
|
|
45
|
-
"index",
|
|
46
|
-
"select"
|
|
47
|
-
]);
|
|
23
|
+
const RefTypeId = Symbol.for("foldkit-surface/ModelRef");
|
|
24
|
+
const makeFocus = (Schema, optic, dependency, get, set) => ({
|
|
25
|
+
Schema,
|
|
26
|
+
optic,
|
|
27
|
+
dependency,
|
|
28
|
+
get,
|
|
29
|
+
set,
|
|
30
|
+
modify: (root, fn) => set(root, fn(get(root)))
|
|
31
|
+
});
|
|
32
|
+
const ModelRef = {
|
|
33
|
+
/**
|
|
34
|
+
* Low-level escape hatch for a focus with no Model path of its own. Prefer
|
|
35
|
+
* the `App.model` tree; use this for an optic that is not part of the Model.
|
|
36
|
+
*/
|
|
37
|
+
fromOptic: (Schema, optic, dependency = []) => ({ [RefTypeId]: makeFocus(Schema, optic, dependency, (root) => Result.getOrThrow(optic.getResult(root)), (root, value) => optic.replace(value, root)) }),
|
|
38
|
+
/**
|
|
39
|
+
* A ref's own members: where it points, how to read and write it, and, as
|
|
40
|
+
* its value allows, `at` (a record), `index` (an array) and `select`. They
|
|
41
|
+
* are kept apart from the ref's string keys, which are the Model's fields.
|
|
42
|
+
*/
|
|
43
|
+
focus: (ref) => ref[RefTypeId],
|
|
44
|
+
/** Whether a value is a ref, as opposed to a Projection or a plain object. */
|
|
45
|
+
is: (value) => typeof value === "object" && value !== null && RefTypeId in value
|
|
46
|
+
};
|
|
48
47
|
function propertyReader(root, key) {
|
|
49
|
-
return root === null || root === void 0 ? void 0 : root[key];
|
|
48
|
+
return root === null || root === void 0 || !Object.hasOwn(root, key) ? void 0 : root[key];
|
|
50
49
|
}
|
|
51
50
|
function optionalReader(value) {
|
|
52
51
|
return value === void 0 ? Option.none() : Option.some(value);
|
|
@@ -63,22 +62,20 @@ const messageTags = (surface) => surface.messages.map(messageTag).filter((tag) =
|
|
|
63
62
|
function makeTree(schema, path, optic, get, optional = false, set, owner) {
|
|
64
63
|
const erasedOptic = optic;
|
|
65
64
|
const setFocus = set ?? ((root, value) => optic.replace(value, root));
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
optic,
|
|
69
|
-
dependency: path,
|
|
65
|
+
const focus = {
|
|
66
|
+
...makeFocus(schema, optic, path, get, setFocus),
|
|
70
67
|
key: path[path.length - 1] ?? "",
|
|
71
|
-
owner
|
|
72
|
-
get,
|
|
73
|
-
set: setFocus,
|
|
74
|
-
modify: (root, fn) => setFocus(root, fn(get(root)))
|
|
68
|
+
owner
|
|
75
69
|
};
|
|
70
|
+
const node = { [RefTypeId]: focus };
|
|
76
71
|
const fields = schema.fields;
|
|
77
|
-
if (fields !== void 0) for (const key of Object.keys(fields)) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
if (fields !== void 0) for (const key of Object.keys(fields)) Object.defineProperty(node, key, {
|
|
73
|
+
value: makeTree(fields[key], [...path, key], erasedOptic.key(key), (root) => propertyReader(get(root), key), false, void 0, owner),
|
|
74
|
+
enumerable: true,
|
|
75
|
+
writable: true,
|
|
76
|
+
configurable: true
|
|
77
|
+
});
|
|
78
|
+
focus.at = (key) => makeTree(schema, [...path, key], erasedOptic.at(key), (root) => optionalReader(propertyReader(get(root), key)), true, (root, value) => {
|
|
82
79
|
const container = get(root);
|
|
83
80
|
const option = value;
|
|
84
81
|
if (Option.isSome(option)) return setFocus(root, {
|
|
@@ -88,13 +85,13 @@ function makeTree(schema, path, optic, get, optional = false, set, owner) {
|
|
|
88
85
|
const { [key]: _removed, ...rest } = container;
|
|
89
86
|
return setFocus(root, rest);
|
|
90
87
|
}, owner);
|
|
91
|
-
|
|
88
|
+
focus.index = (index) => makeTree(schema, [...path, String(index)], optic, (root) => optionalReader(Array.isArray(get(root)) ? get(root)[index] : void 0), true, (root, value) => {
|
|
92
89
|
const array = Array.isArray(get(root)) ? get(root) : [];
|
|
93
90
|
const option = value;
|
|
94
91
|
const next = Option.isSome(option) ? array.map((item, i) => i === index ? option.value : item) : array.filter((_, i) => i !== index);
|
|
95
92
|
return setFocus(root, next);
|
|
96
93
|
}, owner);
|
|
97
|
-
|
|
94
|
+
focus.select = (projection) => {
|
|
98
95
|
const dependencies = mergeDependencies([path, ...projection.dependencies]);
|
|
99
96
|
return optional ? makeProjection(Schema.Option(projection.Model), dependencies, (root) => Option.map(get(root), (value) => projection.read(value)), projection.metadata) : makeProjection(projection.Model, dependencies, (root) => projection.read(get(root)), projection.metadata);
|
|
100
97
|
};
|
|
@@ -128,48 +125,77 @@ function makeProjection(Model, dependencies, read, metadata = Metadata$1.empty)
|
|
|
128
125
|
function objectSchema(fields) {
|
|
129
126
|
return Object.keys(fields).length === 0 ? Schema.Record(Schema.String, Schema.Never) : Schema.Struct(fields);
|
|
130
127
|
}
|
|
128
|
+
const readsUnnamed = /* @__PURE__ */ new WeakSet();
|
|
129
|
+
const unnamed = (entry) => entry.dependencies.length === 0 || readsUnnamed.has(entry);
|
|
130
|
+
const markedBy = (composed, parts) => {
|
|
131
|
+
if (parts.some(unnamed)) readsUnnamed.add(composed);
|
|
132
|
+
return composed;
|
|
133
|
+
};
|
|
134
|
+
const valueAt = (root, path) => {
|
|
135
|
+
let value = root;
|
|
136
|
+
for (const key of path) {
|
|
137
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
138
|
+
value = value[key];
|
|
139
|
+
}
|
|
140
|
+
return value;
|
|
141
|
+
};
|
|
142
|
+
const keepAlike = (before, value) => sameFields(before, value) ? before : value;
|
|
143
|
+
const sameFields = (left, right) => {
|
|
144
|
+
if (Object.is(left, right)) return true;
|
|
145
|
+
if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) return false;
|
|
146
|
+
const prototype = Object.getPrototypeOf(left);
|
|
147
|
+
if (!(prototype === Object.prototype || prototype === null || Array.isArray(left)) || Object.getPrototypeOf(right) !== prototype) return false;
|
|
148
|
+
const keys = Object.keys(left);
|
|
149
|
+
return keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && Object.is(left[key], right[key]));
|
|
150
|
+
};
|
|
131
151
|
const Projection = {
|
|
132
152
|
of: (schema) => (selection) => {
|
|
133
|
-
const picked =
|
|
153
|
+
const picked = Object.create(null);
|
|
134
154
|
const dependencies = [];
|
|
135
155
|
const metadata = [];
|
|
156
|
+
const parts = [];
|
|
136
157
|
const readers = [];
|
|
137
158
|
for (const key of Object.keys(selection)) {
|
|
138
159
|
const choice = selection[key];
|
|
139
160
|
if (choice === true) {
|
|
140
161
|
picked[key] = schema.fields[key];
|
|
162
|
+
parts.push({ dependencies: [] });
|
|
141
163
|
readers.push([key, (root) => propertyReader(root, key)]);
|
|
142
164
|
} else {
|
|
143
165
|
const nested = choice;
|
|
144
166
|
picked[key] = nested.Model;
|
|
145
167
|
dependencies.push(...nested.dependencies);
|
|
146
168
|
metadata.push(nested.metadata);
|
|
169
|
+
parts.push(nested);
|
|
147
170
|
readers.push([key, (root) => nested.read(propertyReader(root, key))]);
|
|
148
171
|
}
|
|
149
172
|
}
|
|
150
173
|
const read = (root) => {
|
|
151
|
-
const out =
|
|
174
|
+
const out = Object.create(null);
|
|
152
175
|
for (const [key, reader] of readers) out[key] = reader(root);
|
|
153
176
|
return out;
|
|
154
177
|
};
|
|
155
|
-
return makeProjection(objectSchema(picked), mergeDependencies(dependencies), read, Metadata$1.combine(metadata));
|
|
178
|
+
return markedBy(makeProjection(objectSchema(picked), mergeDependencies(dependencies), read, Metadata$1.combine(metadata)), parts);
|
|
156
179
|
},
|
|
157
180
|
struct: (entries) => {
|
|
158
181
|
const picked = Object.create(null);
|
|
159
182
|
const dependencies = [];
|
|
160
183
|
const metadata = [];
|
|
184
|
+
const nesteds = [];
|
|
161
185
|
const readers = [];
|
|
162
186
|
for (const key of Object.keys(entries)) {
|
|
163
187
|
const entry = entries[key];
|
|
164
|
-
if (
|
|
188
|
+
if (ModelRef.is(entry)) {
|
|
189
|
+
const focus = entry[RefTypeId];
|
|
190
|
+
picked[key] = focus.Schema;
|
|
191
|
+
dependencies.push(focus.dependency);
|
|
192
|
+
readers.push([key, focus.get]);
|
|
193
|
+
} else {
|
|
165
194
|
picked[key] = entry.Model;
|
|
166
195
|
dependencies.push(...entry.dependencies);
|
|
167
196
|
metadata.push(entry.metadata);
|
|
197
|
+
nesteds.push(entry);
|
|
168
198
|
readers.push([key, entry.read]);
|
|
169
|
-
} else {
|
|
170
|
-
picked[key] = entry.Schema;
|
|
171
|
-
dependencies.push(entry.dependency);
|
|
172
|
-
readers.push([key, entry.get]);
|
|
173
199
|
}
|
|
174
200
|
}
|
|
175
201
|
const read = (root) => {
|
|
@@ -177,26 +203,26 @@ const Projection = {
|
|
|
177
203
|
for (const [key, reader] of readers) out[key] = reader(root);
|
|
178
204
|
return out;
|
|
179
205
|
};
|
|
180
|
-
return makeProjection(objectSchema(picked), mergeDependencies(dependencies), read, Metadata$1.combine(metadata));
|
|
206
|
+
return markedBy(makeProjection(objectSchema(picked), mergeDependencies(dependencies), read, Metadata$1.combine(metadata)), nesteds);
|
|
181
207
|
},
|
|
182
208
|
/**
|
|
183
209
|
* Maps a Projection over an array: `array(p): Projection<ReadonlyArray<Root>,
|
|
184
210
|
* ReadonlyArray<Value>>`. Nesting is explicit (an array of arrays stays an
|
|
185
211
|
* array of arrays); there is no flatten or double-wrap.
|
|
186
212
|
*/
|
|
187
|
-
array: (projection) => ({
|
|
213
|
+
array: (projection) => markedBy({
|
|
188
214
|
Model: Schema.Array(projection.Model),
|
|
189
215
|
dependencies: projection.dependencies,
|
|
190
216
|
metadata: projection.metadata,
|
|
191
217
|
read: (root) => root.map((value) => projection.read(value))
|
|
192
|
-
}),
|
|
218
|
+
}, [projection]),
|
|
193
219
|
/** Maps a Projection inside an Option, preserving absence. */
|
|
194
|
-
option: (projection) => ({
|
|
220
|
+
option: (projection) => markedBy({
|
|
195
221
|
Model: Schema.Option(projection.Model),
|
|
196
222
|
dependencies: projection.dependencies,
|
|
197
223
|
metadata: projection.metadata,
|
|
198
224
|
read: (root) => Option.map(root, (value) => projection.read(value))
|
|
199
|
-
}),
|
|
225
|
+
}, [projection]),
|
|
200
226
|
read: (projection, root) => projection.read(root),
|
|
201
227
|
/**
|
|
202
228
|
* Low-level escape hatch: a Projection from a Schema and a reader, for
|
|
@@ -210,6 +236,48 @@ const Projection = {
|
|
|
210
236
|
read
|
|
211
237
|
}),
|
|
212
238
|
/**
|
|
239
|
+
* A value worked out from the Model, and worked out again only when a value
|
|
240
|
+
* at a path it reads is a new object: the value counterpart of
|
|
241
|
+
* `foldkit-mixins`' `SlotView.region`, and what a region can be drawn from.
|
|
242
|
+
* `on` names what `derive` reads, as field references or Projections;
|
|
243
|
+
* `derive` must read nothing else, or it shows what it read last. While
|
|
244
|
+
* something in `on` reads what no path of its names (a Remote read, alone or
|
|
245
|
+
* inside a `struct`), the value is worked out on every read. A result with
|
|
246
|
+
* the same fields as the last, shallowly, gives the last back, so a memo
|
|
247
|
+
* keyed on it holds. It keeps one result: the one for the last Model it was
|
|
248
|
+
* given.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* const shown = Projection.derive([App.model.todos, App.model.filter], (model: Model) =>
|
|
253
|
+
* model.todos.filter(todo => model.filter === 'all' || todo.done === (model.filter === 'done')),
|
|
254
|
+
* )
|
|
255
|
+
* // In the view: shown.read(model)
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
derive: (on, derive) => {
|
|
259
|
+
if (on.length === 0) throw new Error("Projection.derive: it names nothing it reads, so nothing could tell it to work the value out again. Name field references, or Projections built from them.");
|
|
260
|
+
const parts = on.map((entry) => RefTypeId in entry ? { dependencies: [entry[RefTypeId].dependency] } : entry);
|
|
261
|
+
const dependencies = mergeDependencies(parts.flatMap((part) => part.dependencies));
|
|
262
|
+
const always = parts.some(unnamed);
|
|
263
|
+
let last;
|
|
264
|
+
const derived = {
|
|
265
|
+
dependencies,
|
|
266
|
+
read: (root) => {
|
|
267
|
+
const values = dependencies.map((path) => valueAt(root, path));
|
|
268
|
+
const before = last;
|
|
269
|
+
const value = before === void 0 ? derive(root) : !always && values.every((value, index) => Object.is(value, before.values[index])) ? before.value : keepAlike(before.value, derive(root));
|
|
270
|
+
last = {
|
|
271
|
+
values,
|
|
272
|
+
value
|
|
273
|
+
};
|
|
274
|
+
return value;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
if (always) readsUnnamed.add(derived);
|
|
278
|
+
return derived;
|
|
279
|
+
},
|
|
280
|
+
/**
|
|
213
281
|
* Derives a writable projection from generated Model field references:
|
|
214
282
|
* `Projection.pick(App.model.todos, App.model.selectedTodoId)` infers
|
|
215
283
|
* `{ todos, selectedTodoId }` and its codec. Every reference must share one
|
|
@@ -217,35 +285,35 @@ const Projection = {
|
|
|
217
285
|
* identical members deduplicate; a conflicting definition throws.
|
|
218
286
|
*/
|
|
219
287
|
pick: (...refs) => {
|
|
220
|
-
const selected = [
|
|
288
|
+
const selected = refs.map((ref) => ref[RefTypeId]);
|
|
221
289
|
const owner = selected[0]?.owner;
|
|
222
|
-
for (const
|
|
223
|
-
const fields =
|
|
224
|
-
const paths =
|
|
225
|
-
for (const
|
|
226
|
-
const path =
|
|
227
|
-
const existing = paths[
|
|
290
|
+
for (const focus of selected) if (focus.owner !== owner) throw new Error("Projection.pick: references from different applications");
|
|
291
|
+
const fields = Object.create(null);
|
|
292
|
+
const paths = Object.create(null);
|
|
293
|
+
for (const focus of [...selected]) {
|
|
294
|
+
const path = focus.dependency.join(".");
|
|
295
|
+
const existing = paths[focus.key];
|
|
228
296
|
if (existing !== void 0) {
|
|
229
297
|
if (existing === path) {
|
|
230
|
-
selected.splice(selected.indexOf(
|
|
298
|
+
selected.splice(selected.indexOf(focus), 1);
|
|
231
299
|
continue;
|
|
232
300
|
}
|
|
233
|
-
throw new Error(`Projection.pick: "${existing}" and "${path}" would both be read as "${
|
|
301
|
+
throw new Error(`Projection.pick: "${existing}" and "${path}" would both be read as "${focus.key}". Pick them in separate projections.`);
|
|
234
302
|
}
|
|
235
|
-
paths[
|
|
236
|
-
fields[
|
|
303
|
+
paths[focus.key] = path;
|
|
304
|
+
fields[focus.key] = focus.Schema;
|
|
237
305
|
}
|
|
238
306
|
return {
|
|
239
307
|
schema: objectSchema(fields),
|
|
240
|
-
dependencies: mergeDependencies(selected.map((
|
|
308
|
+
dependencies: mergeDependencies(selected.map((focus) => focus.dependency)),
|
|
241
309
|
get: (model) => {
|
|
242
|
-
const out =
|
|
243
|
-
for (const
|
|
310
|
+
const out = Object.create(null);
|
|
311
|
+
for (const focus of selected) out[focus.key] = focus.get(model);
|
|
244
312
|
return out;
|
|
245
313
|
},
|
|
246
314
|
set: (model, shared) => {
|
|
247
315
|
let next = model;
|
|
248
|
-
for (const
|
|
316
|
+
for (const focus of selected) next = focus.set(next, shared[focus.key]);
|
|
249
317
|
return next;
|
|
250
318
|
}
|
|
251
319
|
};
|
|
@@ -258,8 +326,8 @@ const Projection = {
|
|
|
258
326
|
*/
|
|
259
327
|
compose: (...projections) => {
|
|
260
328
|
const parts = [...projections];
|
|
261
|
-
const fields =
|
|
262
|
-
const paths =
|
|
329
|
+
const fields = Object.create(null);
|
|
330
|
+
const paths = Object.create(null);
|
|
263
331
|
const pathOf = (part, key) => part.dependencies.find((dependency) => dependency.at(-1) === key)?.join(".");
|
|
264
332
|
for (const part of parts) for (const [key, codec] of Object.entries(part.schema.fields)) {
|
|
265
333
|
const existing = fields[key];
|
|
@@ -277,7 +345,7 @@ const Projection = {
|
|
|
277
345
|
schema: objectSchema(fields),
|
|
278
346
|
dependencies: mergeDependencies(parts.flatMap((part) => [...part.dependencies])),
|
|
279
347
|
get: (model) => {
|
|
280
|
-
const out =
|
|
348
|
+
const out = Object.create(null);
|
|
281
349
|
for (const part of parts) Object.assign(out, part.get(model));
|
|
282
350
|
return out;
|
|
283
351
|
},
|
|
@@ -449,8 +517,9 @@ const Surface = {
|
|
|
449
517
|
when: (surface, place, tagged, params) => {
|
|
450
518
|
const tag = messageTag(tagged);
|
|
451
519
|
if (tag === void 0) throw new Error(`Surface.when: expected a tagged constructor for "${surface.name}", which is what names the case that activates it`);
|
|
520
|
+
const focus = place[RefTypeId];
|
|
452
521
|
const paramsOf = (model) => {
|
|
453
|
-
const value =
|
|
522
|
+
const value = focus.get(model);
|
|
454
523
|
return Predicate.isTagged(value, tag) ? Option.some(params(value)) : Option.none();
|
|
455
524
|
};
|
|
456
525
|
return {
|
|
@@ -458,7 +527,7 @@ const Surface = {
|
|
|
458
527
|
owner: surface.owner,
|
|
459
528
|
messages: messageTags(surface),
|
|
460
529
|
activation: {
|
|
461
|
-
path:
|
|
530
|
+
path: focus.dependency,
|
|
462
531
|
tag
|
|
463
532
|
},
|
|
464
533
|
projectionOf: (model) => Option.map(paramsOf(model), surface.projection),
|
|
@@ -526,10 +595,13 @@ const Surface = {
|
|
|
526
595
|
*/
|
|
527
596
|
instances: (source, model) => source.instancesOf(model),
|
|
528
597
|
make: (app, name, config) => {
|
|
529
|
-
const projection = (params) =>
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
598
|
+
const projection = (params) => {
|
|
599
|
+
if (params === void 0 && config.Params !== void 0 && !Schema.is(config.Params)(void 0)) throw new Error(`Surface "${name}" declares params, and was given none`);
|
|
600
|
+
return config.model({
|
|
601
|
+
model: app.model,
|
|
602
|
+
params
|
|
603
|
+
});
|
|
604
|
+
};
|
|
533
605
|
return {
|
|
534
606
|
name,
|
|
535
607
|
owner: app.owner,
|
|
@@ -539,7 +611,7 @@ const Surface = {
|
|
|
539
611
|
projection
|
|
540
612
|
};
|
|
541
613
|
},
|
|
542
|
-
read: (surface, root, params) => surface.projection(params).read(root),
|
|
614
|
+
read: (surface, root, ...params) => surface.projection(params[0]).read(root),
|
|
543
615
|
/**
|
|
544
616
|
* Binds a renderer to a Surface's projected Model and Message set. A
|
|
545
617
|
* type-level binder: the renderer already has this shape, but `Model` and
|
|
@@ -565,8 +637,8 @@ const Surface = {
|
|
|
565
637
|
* A Surface as a `Contract` for `Module`: what it observes, requires, and may
|
|
566
638
|
* emit. A parameterized Surface needs its `params` to build the projection.
|
|
567
639
|
*/
|
|
568
|
-
contract: (surface, params) => {
|
|
569
|
-
const projection = surface.projection(params);
|
|
640
|
+
contract: (surface, ...params) => {
|
|
641
|
+
const projection = surface.projection(params[0]);
|
|
570
642
|
return {
|
|
571
643
|
kind: "surface",
|
|
572
644
|
name: surface.name,
|
|
@@ -581,8 +653,8 @@ const Surface = {
|
|
|
581
653
|
* Pure introspection for DevTools: what a Surface observes (dependencies,
|
|
582
654
|
* requirements) and what it may emit. No behavior change, no I/O.
|
|
583
655
|
*/
|
|
584
|
-
inspect: (surface, params) => {
|
|
585
|
-
const projection = surface.projection(params);
|
|
656
|
+
inspect: (surface, ...params) => {
|
|
657
|
+
const projection = surface.projection(params[0]);
|
|
586
658
|
return {
|
|
587
659
|
name: surface.name,
|
|
588
660
|
dependencies: projection.dependencies,
|
|
@@ -760,7 +832,6 @@ const Module = {
|
|
|
760
832
|
return lines.join("\n");
|
|
761
833
|
}
|
|
762
834
|
};
|
|
763
|
-
|
|
764
|
-
export { Action, MessageSet, Metadata, MetadataTypeId, ModelRef, Module, Projection, Surface };
|
|
835
|
+
export { Action, Diagnostics, MessageSet, Metadata, MetadataTypeId, ModelRef, Module, Projection, RefTypeId, Surface };
|
|
765
836
|
|
|
766
|
-
//# sourceMappingURL=index.
|
|
837
|
+
//# sourceMappingURL=index.js.map
|