@mark1russell7/room-view 0.2.1 → 0.2.2

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 CHANGED
@@ -264,7 +264,27 @@ const marks = layerMarks(scene, addOns, addOnMarks);
264
264
  - A layer with a fault of its form gives no marks, and `checkLayers` tells the fault.
265
265
  - A mark is plain data in meters, with the z axis up. It has no shape and no color.
266
266
 
267
- `ANCHOR_CODES` and `LAYER_CODES` have the codes of the core. The design of the add-ons is in `docs/ADD-ONS.md` of the repository.
267
+ An add-on can give the form of its layer as data, a `LayerForm` value. It has the collections of the records and the fields of each record. A page makes its inputs from this data, so the page has no code of a topic:
268
+
269
+ ```ts
270
+ import { formLayer, formRecords } from "@mark1russell7/room-view";
271
+
272
+ // The layer of the records that a person typed, with the usual values of a home with feet and inches:
273
+ const layer = formLayer(form, records, { system: "imperial" });
274
+ // The records of a layer, for the inputs of a page:
275
+ const read = formRecords(form, layer);
276
+ ```
277
+
278
+ - A field is a text, a number in a fixed unit, or the `id` of a record or of a placed object.
279
+ - The record of a field is in the same layer.
280
+ - A collection with surfaces has records with an anchor. A collection with an owner has the records of a placed object or of a different record.
281
+ - `formLayer` is total. A record with a value that is not valid, or with no value of a necessary field, is not in the layer.
282
+ - A number with no value gets the usual value of its field for the system of units, `metric` or `imperial`.
283
+ - `formRecords` gives `more: true` when the layer has data that the form does not keep. Thus a page can tell that an edit loses data.
284
+ - `readFormRecord` gives the first field that stops a record, so a page can show the fault at its input.
285
+ - `checkForm` gives the faults of a form. An add-on examines its form with this function in a test.
286
+
287
+ `ANCHOR_CODES`, `LAYER_CODES` and `FORM_CODES` have the codes of the core. The design of the add-ons is in `docs/ADD-ONS.md` of the repository.
268
288
 
269
289
  ## The loads of the circuits
270
290
 
package/build/index.d.ts CHANGED
@@ -39,5 +39,190 @@ export interface PlanOptions extends SolidOptions {
39
39
  * Thus a drawing in this sequence shows the room as a camera above it sees the room.
40
40
  */
41
41
  export declare function planShapes(scene: Scene, options?: PlanOptions): readonly PlanShape[];
42
+ /** These are the systems of units of a person. A usual value has one number for each system. */
43
+ export declare const FORM_SYSTEMS: readonly ["metric", "imperial"];
44
+ /** A system of units of a person. */
45
+ export type FormSystem = (typeof FORM_SYSTEMS)[number];
46
+ /** The usual value of a number for each system of units. A page shows it in a field that has no value. */
47
+ export type FormUsual = Readonly<Record<FormSystem, number>>;
48
+ /** These are the kinds of a field of a record. */
49
+ export declare const FORM_FIELD_KINDS: readonly ["text", "number", "record", "object"];
50
+ /** The kind of a field of a record. */
51
+ export type FormFieldKind = (typeof FORM_FIELD_KINDS)[number];
52
+ /** The parts that each field of a record has. */
53
+ export interface FormFieldPart {
54
+ /** The name of the field in a record of the layer, for example `breaker`. */
55
+ readonly name: string;
56
+ /** The name of the field in a page, for example `Breaker`. */
57
+ readonly label: string;
58
+ /** This value is true when a record needs a value of the field. A record with no value of it is not in the layer. */
59
+ readonly needed?: boolean | undefined;
60
+ }
61
+ /** A field with a text, for example the name of a circuit. */
62
+ export interface FormTextField extends FormFieldPart {
63
+ readonly kind: "text";
64
+ }
65
+ /** A field with a number in a fixed unit, for example the rating of a breaker in amperes. */
66
+ export interface FormNumberField extends FormFieldPart {
67
+ readonly kind: "number";
68
+ /** The text of the unit in a page, for example `A`. */
69
+ readonly unit?: string | undefined;
70
+ /** The value of a record that has no value of the field. */
71
+ readonly usual?: FormUsual | undefined;
72
+ /** A valid value is above this number. */
73
+ readonly above?: number | undefined;
74
+ /** A valid value is this number or more. */
75
+ readonly least?: number | undefined;
76
+ /** The sentence of a page for a value that is not valid. It tells the person the value to type. */
77
+ readonly fault?: string | undefined;
78
+ }
79
+ /** A field with the `id` of a record of a collection of the same layer, for example the circuit of an outlet. */
80
+ export interface FormRecordField extends FormFieldPart {
81
+ readonly kind: "record";
82
+ /** The name of the collection of the record. */
83
+ readonly of: string;
84
+ /** The text of a page for no record, for example `No circuit`. */
85
+ readonly none?: string | undefined;
86
+ /** The sentence of help of a page when the collection has no record. It tells the way to the first record. */
87
+ readonly aid?: string | undefined;
88
+ }
89
+ /** A field with the `id` of a placed object of the scene, for example the object of a power feed. */
90
+ export interface FormObjectField extends FormFieldPart {
91
+ readonly kind: "object";
92
+ }
93
+ /** A field of a record of a form. */
94
+ export type FormField = FormTextField | FormNumberField | FormRecordField | FormObjectField;
95
+ /**
96
+ * A collection of a form: the records of one field of a layer, for example the circuits.
97
+ *
98
+ * - A collection with `on` has records with a place. A page shows them with the surface of their anchor.
99
+ * - A collection with `owner` has records of an owner. A page shows them with their owner.
100
+ * - Each other collection is a list of the level.
101
+ */
102
+ export interface FormCollection {
103
+ /** The name of the field of the layer that has the records, for example `circuits`. */
104
+ readonly name: string;
105
+ /** The word of one record for its `id`. For example, `circuit` gives the `id` `circuit-1`. */
106
+ readonly word: string;
107
+ /** The name of one record in a page, for example `Circuit`. */
108
+ readonly label: string;
109
+ /** The title of the records in a page, for example `Circuits`. */
110
+ readonly title: string;
111
+ /** The surfaces of the anchor of a record. A collection with no surfaces has records with no place. */
112
+ readonly on?: readonly AnchorSurface[] | undefined;
113
+ /** The usual height of a record on a wall above the floor, in meters. */
114
+ readonly height?: FormUsual | undefined;
115
+ /** The fields of a record, in the sequence of a page. */
116
+ readonly fields: readonly FormField[];
117
+ /** The name of the text field that gives the words of the `id` of a record. Without it, the `id` has the word and a number. */
118
+ readonly idFrom?: string | undefined;
119
+ /** The name of the field that names the owner of a record. It is a necessary field of the kind `object` or `record`. */
120
+ readonly owner?: string | undefined;
121
+ /** The largest number of records of one owner. */
122
+ readonly most?: number | undefined;
123
+ }
124
+ /** The form of a layer. The add-on of the layer gives it as data. */
125
+ export interface LayerForm {
126
+ /** The name of the format of the layer, for example `electrical/1`. */
127
+ readonly schema: string;
128
+ /** The collections of the layer, in the sequence of a page. */
129
+ readonly collections: readonly FormCollection[];
130
+ }
131
+ /** These are the codes of the faults of a form. */
132
+ export declare const FORM_CODES: readonly ["form-schema", "form-collection", "form-field"];
133
+ /** The code of a fault of a form. */
134
+ export type FormCode = (typeof FORM_CODES)[number];
135
+ /** A fault of a form. */
136
+ export interface FormFault {
137
+ readonly code: FormCode;
138
+ /** The name of the collection, or the names of the collection and of the field with a point between them. For the form, it is empty. */
139
+ readonly at: string;
140
+ /** The fault in plain words, with the values. */
141
+ readonly message: string;
142
+ }
143
+ /**
144
+ * This function gives the faults of a form. A form with no fault is safe for `formLayer` and `formRecords`.
145
+ * The test of an add-on examines its form with this function.
146
+ */
147
+ export declare function checkForm(form: LayerForm): readonly FormFault[];
148
+ /** A value of a field: a text, a number, or the `id` of a record or of a placed object. */
149
+ export type FormValue = string | number;
150
+ /** A record of a form: the values that a person gave. */
151
+ export interface FormRecord {
152
+ readonly id: string;
153
+ /** The place of the record, for a collection with surfaces. */
154
+ readonly anchor?: Anchor | undefined;
155
+ /** The value of each field, by the name of the field. A field with no value is absent. */
156
+ readonly values: Readonly<Record<string, FormValue>>;
157
+ }
158
+ /** The records of a form, by the name of each collection. */
159
+ export type FormRecords = Readonly<Record<string, readonly FormRecord[]>>;
160
+ /**
161
+ * The read of a record: its valid values, or the first field that stops the record.
162
+ * The state `empty` tells a necessary field with no value, and the state `bad` tells a value that is not valid. The field of the place is `anchor`.
163
+ */
164
+ export type FormReading = {
165
+ readonly state: "ok";
166
+ readonly values: Readonly<Record<string, FormValue>>;
167
+ } | {
168
+ readonly state: "empty" | "bad";
169
+ readonly field: string;
170
+ };
171
+ /**
172
+ * This function reads the values of a record of a collection.
173
+ *
174
+ * - A number field with no value gets its usual value for the system.
175
+ * - A text loses the spaces at its ends. An empty text is no value.
176
+ * - A number that is not valid, or a value of a different type, stops the record.
177
+ * - A necessary field with no value stops the record. A collection with surfaces needs an anchor on one of them.
178
+ *
179
+ * The function does not examine if a record or an object of a field is there. `formLayer` examines it.
180
+ */
181
+ export declare function readFormRecord(collection: FormCollection, record: FormRecord, system: FormSystem): FormReading;
182
+ /** The options of `formLayer`. */
183
+ export interface FormLayerOptions {
184
+ /** The system of units of the person, for the usual value of each number. */
185
+ readonly system: FormSystem;
186
+ /** The ids of the placed objects of the scene. With it, a field of the kind `object` keeps only an `id` of the set. */
187
+ readonly objects?: ReadonlySet<string> | undefined;
188
+ }
189
+ /** A layer from the records of a form: its name, and the records of each collection that has records. */
190
+ export type FormLayer = Readonly<Record<string, unknown>> & {
191
+ readonly schema: string;
192
+ };
193
+ /**
194
+ * This function makes the layer of the records of a form. It is total: a record that the layer cannot have is not in the layer.
195
+ *
196
+ * - `readFormRecord` reads each record. A record that it stops is not in the layer.
197
+ * - The ids of a layer are unique. The first record of an `id` stays, in the sequence of the collections.
198
+ * - A field that names a record that is not in the layer has no value. A record with no value of a necessary field is not in the layer.
199
+ * - A collection with no record is not in the layer.
200
+ *
201
+ * A record of the layer has its `id`, then its `anchor`, then its values in the sequence of the fields. Thus equal records give equal JSON.
202
+ * The add-on of the layer reads the result with its `parse`, and `checkLayers` examines it.
203
+ */
204
+ export declare function formLayer(form: LayerForm, records: FormRecords, options: FormLayerOptions): FormLayer;
205
+ /** The records of a form from a layer. */
206
+ export interface FormRecordsRead {
207
+ /** The records of each collection of the form. A collection with no record has an empty list. */
208
+ readonly records: FormRecords;
209
+ /** This value is true when the layer has data that the form does not keep. */
210
+ readonly more: boolean;
211
+ }
212
+ /**
213
+ * This function gives the records of a form from a layer. Give it a layer that its add-on read: the function does not examine the form of an anchor.
214
+ *
215
+ * The form does not keep these data, and `more` tells them:
216
+ *
217
+ * - a field of the layer or of a record that the form does not have
218
+ * - a record with no `id`, or with the `id` of an earlier record
219
+ * - a record of a collection with surfaces that has no anchor on one of them
220
+ * - a value that is not a valid value of its field
221
+ * - a field that names a record that the layer does not have
222
+ * - a record after the largest number of records of its owner
223
+ *
224
+ * The records of a layer of `formLayer` are the records that the layer has, and `more` is false for them.
225
+ */
226
+ export declare function formRecords(form: LayerForm, layer: unknown): FormRecordsRead;
42
227
  export { ANCHOR_CODES, ANCHOR_SURFACES, AddOn, AddOnFault, Anchor, AnchorCode, AnchorFault, AnchorFrame, AnchorSurface, CLOSURE_LIMIT, CONNECTION_FAULTS, CONNECTION_TURN_LIMIT, CONNECTION_USES, CeilingAnchor, CheckOptions, Circuit, CircuitLoad, CircuitState, ConnectionEnd, ConnectionFault, ConnectionUse, FINDING_CODES, FINDING_LEVELS, FLOOR_DEPTH, Finding, FindingCode, FindingLevel, Floor, FloorAnchor, GLASS_THICKNESS, JOIN_TOLERANCE, JoinOptions, LARGEST_LENGTH, LAYER_CODES, LENGTH_UNITS, LEVEL_SCHEMA, LEVEL_SHAPES, LOAD_LEVELS, LayerFinding, LayerParse, LengthUnit, Level, LevelConnection, LevelConnectionResult, LevelOptions, LevelResult, LevelRoom, LevelRoomResult, LevelShape, LoadLevel, LoadOptions, MITER_LIMIT, NEAR_LIMIT, OPENING_KINDS, OUTLET_PLATE, ObjectAnchor, Opening, OpeningKind, Outlet, PlacedBox, PlacedObject, PlanPoint, Prism, RECORD_KINDS, ROOM_PLACES, ROOM_SCHEMA, RecordKind, Room, RoomPlace, SCENE_SCHEMA, SHAPE_OUTLINES, SOLID_KINDS, SQUARE_TURNS, SURVEY_SCHEMA, Scene, SceneSpace, ShapeOutline, Solid, SolidKind, SolidOptions, SolidShape, Survey, SurveyCheck, SurveyCheckResult, SurveyClosure, SurveyObject, SurveyOptions, SurveyOutlet, SurveyResult, SurveySide, SurveyTurn, TO_Y_UP, WALL_FACES, WALL_SIDES, Wall, WallAnchor, WallFace, WallFootprint, WallFrame, WallSide, boundsOfSolids, checkAnchor, checkLayers, checkRoom, checkScene, circuitStates, convertSurvey, expandLevel, expandSurvey, isLayerName, lengthsInRange, levelShape, metersPer, objectTransforms, outletLevels, parseRecordName, readLayer, recordName, roomSolids, sceneSolids, sceneSpace, shapeRing, solidCorners, solidRecord, solidVolume, unitsPer, wallFootprints, wallFrames, wallHasOutline, wallPoint, wallTransform };
43
228
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/plan.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N,QAAQ;;WAER,UAAU;;;YAIT,YAAY,SAAS;WAAsC;;;;;;;;;;;;;wBAavD,UAAU,MAAM,WAAW,SAAS,aAAa,SAAS,mBAAmB;;iBAoC5E;;WAEN,SAAS;;WAET;;;;;;;;;;;;;;;;wBAmBK,YAAY,MAAM,WAAW,iBAAiB"}
package/build/index.js CHANGED
@@ -70,6 +70,343 @@ function planShapes(scene, options = {}) {
70
70
  index
71
71
  })).sort((a, b) => a.shape.top - b.shape.top || a.index - b.index).map(({ shape }) => shape);
72
72
  }
73
- export { ANCHOR_CODES, ANCHOR_SURFACES, CLOSURE_LIMIT, CONNECTION_FAULTS, CONNECTION_TURN_LIMIT, CONNECTION_USES, FINDING_CODES, FINDING_LEVELS, FLOOR_DEPTH, GLASS_THICKNESS, JOIN_TOLERANCE, LARGEST_LENGTH, LAYER_CODES, LENGTH_UNITS, LEVEL_SCHEMA, LEVEL_SHAPES, LOAD_LEVELS, MITER_LIMIT, NEAR_LIMIT, OPENING_KINDS, OUTLET_PLATE, RECORD_KINDS, ROOM_PLACES, ROOM_SCHEMA, SCENE_SCHEMA, SHAPE_OUTLINES, SOLID_KINDS, SQUARE_TURNS, SURVEY_SCHEMA, TO_Y_UP, WALL_FACES, WALL_SIDES, boundsOfSolids, checkAnchor, checkLayers, checkRoom, checkScene, circuitStates, convertSurvey, expandLevel, expandSurvey, isLayerName, lengthsInRange, levelShape, metersPer, objectTransforms, outletLevels, parseRecordName, planShape, planShapes, readLayer, recordName, roomSolids, sceneSolids, sceneSpace, shapeRing, solidCorners, solidRecord, solidVolume, unitsPer, wallFootprints, wallFrames, wallHasOutline, wallPoint, wallTransform };
73
+ // src/form.ts
74
+ /** These are the systems of units of a person. A usual value has one number for each system. */
75
+ const FORM_SYSTEMS = ["metric", "imperial"];
76
+ /** These are the kinds of a field of a record. */
77
+ const FORM_FIELD_KINDS = [
78
+ "text",
79
+ "number",
80
+ "record",
81
+ "object"
82
+ ];
83
+ /** These are the codes of the faults of a form. */
84
+ const FORM_CODES = [
85
+ "form-schema",
86
+ "form-collection",
87
+ "form-field"
88
+ ];
89
+ /** The names that a field cannot have: the parts of each record, and a name that changes an object of JavaScript. */
90
+ const RESERVED = /* @__PURE__ */ new Set([
91
+ "id",
92
+ "anchor",
93
+ "__proto__"
94
+ ]);
95
+ /** This function tells if a number is a valid value of a number field. */
96
+ function numberFits(field, value) {
97
+ return Number.isFinite(value) && (field.above === void 0 || value > field.above) && (field.least === void 0 || value >= field.least);
98
+ }
99
+ /** This function gives the names that are in a list two times or more. */
100
+ function repeated(names) {
101
+ const seen = /* @__PURE__ */ new Set();
102
+ const twice = /* @__PURE__ */ new Set();
103
+ for (const name of names) (seen.has(name) ? twice : seen).add(name);
104
+ return twice;
105
+ }
106
+ /**
107
+ * This function gives the faults of a form. A form with no fault is safe for `formLayer` and `formRecords`.
108
+ * The test of an add-on examines its form with this function.
109
+ */
110
+ function checkForm(form) {
111
+ const faults = [];
112
+ if (!isLayerName(form.schema)) faults.push({
113
+ code: "form-schema",
114
+ at: "",
115
+ message: `The form has the name "${form.schema}", which is not a word, a slash and a version, for example "electrical/1".`
116
+ });
117
+ const names = new Set(form.collections.map((collection) => collection.name));
118
+ const twice = repeated(form.collections.map((collection) => collection.name));
119
+ for (const collection of form.collections) {
120
+ const at = collection.name;
121
+ const fault = (message) => {
122
+ faults.push({
123
+ code: "form-collection",
124
+ at,
125
+ message: `The collection "${at}" ${message}`
126
+ });
127
+ };
128
+ if (at === "" || at === "schema" || at === "__proto__") fault("has a name that a layer cannot have.");
129
+ if (twice.has(at)) fault("is in the form two times.");
130
+ if (collection.word === "") fault("has no word for the ids of its records.");
131
+ if (collection.on !== void 0 && (collection.on.length === 0 || repeated(collection.on).size > 0)) fault("has a list of surfaces that is empty, or that has a surface two times.");
132
+ if (collection.height !== void 0 && !(collection.on ?? []).includes("wall")) fault("has a usual height, and its records are not on a wall.");
133
+ if (collection.height !== void 0 && !FORM_SYSTEMS.every((system) => Number.isFinite(collection.height?.[system]))) fault("has a usual height that is not a number.");
134
+ if (collection.most !== void 0 && (!Number.isInteger(collection.most) || collection.most < 1)) fault(`has the largest number ${String(collection.most)}, which is not an integer of 1 or more.`);
135
+ if (collection.most !== void 0 && collection.owner === void 0) fault("has a largest number of records of one owner, and it has no owner.");
136
+ const fields = new Map(collection.fields.map((field) => [field.name, field]));
137
+ if (collection.owner !== void 0) {
138
+ const owner = fields.get(collection.owner);
139
+ if (owner === void 0 || owner.needed !== true || owner.kind !== "object" && owner.kind !== "record") fault(`has the owner "${collection.owner}", which is not a necessary field of the kind "object" or "record".`);
140
+ }
141
+ if (collection.idFrom !== void 0 && fields.get(collection.idFrom)?.kind !== "text") fault(`takes its ids from "${collection.idFrom}", which is not a text field.`);
142
+ const twiceFields = repeated(collection.fields.map((field) => field.name));
143
+ for (const field of collection.fields) {
144
+ const place = `${at}.${field.name}`;
145
+ const fieldFault = (message) => {
146
+ faults.push({
147
+ code: "form-field",
148
+ at: place,
149
+ message: `The field "${field.name}" of the collection "${at}" ${message}`
150
+ });
151
+ };
152
+ if (field.name === "" || RESERVED.has(field.name)) fieldFault("has a name that a field cannot have.");
153
+ if (twiceFields.has(field.name)) fieldFault("is in the collection two times.");
154
+ if (field.kind === "record" && !names.has(field.of)) fieldFault(`names the collection "${field.of}", which the form does not have.`);
155
+ if (field.kind === "number") {
156
+ if (field.above !== void 0 && !Number.isFinite(field.above) || field.least !== void 0 && !Number.isFinite(field.least)) fieldFault("has a limit that is not a number.");
157
+ if (field.usual !== void 0 && !FORM_SYSTEMS.every((system) => numberFits(field, field.usual?.[system] ?? NaN))) fieldFault("has a usual value that is not a valid value.");
158
+ }
159
+ }
160
+ }
161
+ return faults;
162
+ }
163
+ /** This function gives the value of a field in the values of a record. A field that the values do not have gives `undefined`. */
164
+ function valueOf(values, name) {
165
+ return Object.hasOwn(values, name) ? values[name] : void 0;
166
+ }
167
+ /**
168
+ * This function reads the values of a record of a collection.
169
+ *
170
+ * - A number field with no value gets its usual value for the system.
171
+ * - A text loses the spaces at its ends. An empty text is no value.
172
+ * - A number that is not valid, or a value of a different type, stops the record.
173
+ * - A necessary field with no value stops the record. A collection with surfaces needs an anchor on one of them.
174
+ *
175
+ * The function does not examine if a record or an object of a field is there. `formLayer` examines it.
176
+ */
177
+ function readFormRecord(collection, record, system) {
178
+ if (collection.on !== void 0) {
179
+ if (record.anchor === void 0) return {
180
+ state: "empty",
181
+ field: "anchor"
182
+ };
183
+ if (!collection.on.includes(record.anchor.on)) return {
184
+ state: "bad",
185
+ field: "anchor"
186
+ };
187
+ }
188
+ const values = [];
189
+ for (const field of collection.fields) {
190
+ const given = valueOf(record.values, field.name);
191
+ if (field.kind === "number") {
192
+ const value = given ?? field.usual?.[system];
193
+ if (value === void 0) {
194
+ if (field.needed === true) return {
195
+ state: "empty",
196
+ field: field.name
197
+ };
198
+ continue;
199
+ }
200
+ if (typeof value !== "number" || !numberFits(field, value)) return {
201
+ state: "bad",
202
+ field: field.name
203
+ };
204
+ values.push([field.name, value]);
205
+ continue;
206
+ }
207
+ if (given !== void 0 && typeof given !== "string") return {
208
+ state: "bad",
209
+ field: field.name
210
+ };
211
+ const text = field.kind === "text" ? (given ?? "").trim() : given ?? "";
212
+ if (text === "") {
213
+ if (field.needed === true) return {
214
+ state: "empty",
215
+ field: field.name
216
+ };
217
+ continue;
218
+ }
219
+ values.push([field.name, text]);
220
+ }
221
+ return {
222
+ state: "ok",
223
+ values: Object.fromEntries(values)
224
+ };
225
+ }
226
+ /**
227
+ * This function removes each part that names a record or an object that is not there, one time. It gives true when it removed a part.
228
+ *
229
+ * - A field of a record that is not in its collection loses its value. A field of an object that is not in `objects` loses its value too.
230
+ * - A record with no value of a necessary field goes away.
231
+ * - A record after the largest number of records of its owner goes away.
232
+ */
233
+ function settleOnce(form, kept, objects) {
234
+ let changed = false;
235
+ const ids = /* @__PURE__ */ new Map();
236
+ for (const collection of form.collections) ids.set(collection.name, new Set((kept.get(collection.name) ?? []).map((record) => record.id)));
237
+ for (const collection of form.collections) {
238
+ const counts = /* @__PURE__ */ new Map();
239
+ const list = [];
240
+ for (const record of kept.get(collection.name) ?? []) {
241
+ let stays = true;
242
+ for (const field of collection.fields) {
243
+ const value = valueOf(record.values, field.name);
244
+ if (typeof value !== "string" || field.kind === "text" || field.kind === "number") continue;
245
+ if (field.kind === "record" ? ids.get(field.of)?.has(value) === true : objects === void 0 || objects.has(value)) continue;
246
+ changed = true;
247
+ if (field.needed === true) stays = false;
248
+ else record.values = Object.fromEntries(Object.entries(record.values).filter(([name]) => name !== field.name));
249
+ }
250
+ if (stays && collection.owner !== void 0 && collection.most !== void 0) {
251
+ const owner = String(valueOf(record.values, collection.owner) ?? "");
252
+ const count = (counts.get(owner) ?? 0) + 1;
253
+ counts.set(owner, count);
254
+ if (count > collection.most) {
255
+ changed = true;
256
+ stays = false;
257
+ }
258
+ }
259
+ if (stays) list.push(record);
260
+ }
261
+ kept.set(collection.name, list);
262
+ }
263
+ return changed;
264
+ }
265
+ /**
266
+ * This function removes each part that names a record or an object that is not there. It gives true when it removed a part.
267
+ * A record that goes away can be the record of a field, so the function repeats `settleOnce` until nothing changes.
268
+ */
269
+ function settle(form, kept, objects) {
270
+ let removed = false;
271
+ while (settleOnce(form, kept, objects)) removed = true;
272
+ return removed;
273
+ }
274
+ /**
275
+ * This function makes the layer of the records of a form. It is total: a record that the layer cannot have is not in the layer.
276
+ *
277
+ * - `readFormRecord` reads each record. A record that it stops is not in the layer.
278
+ * - The ids of a layer are unique. The first record of an `id` stays, in the sequence of the collections.
279
+ * - A field that names a record that is not in the layer has no value. A record with no value of a necessary field is not in the layer.
280
+ * - A collection with no record is not in the layer.
281
+ *
282
+ * A record of the layer has its `id`, then its `anchor`, then its values in the sequence of the fields. Thus equal records give equal JSON.
283
+ * The add-on of the layer reads the result with its `parse`, and `checkLayers` examines it.
284
+ */
285
+ function formLayer(form, records, options) {
286
+ const kept = /* @__PURE__ */ new Map();
287
+ const seen = /* @__PURE__ */ new Set();
288
+ for (const collection of form.collections) {
289
+ const list = [];
290
+ for (const record of Object.hasOwn(records, collection.name) ? records[collection.name] ?? [] : []) {
291
+ if (record.id === "" || seen.has(record.id)) continue;
292
+ const reading = readFormRecord(collection, record, options.system);
293
+ if (reading.state !== "ok") continue;
294
+ seen.add(record.id);
295
+ list.push({
296
+ id: record.id,
297
+ anchor: collection.on === void 0 ? void 0 : record.anchor,
298
+ values: reading.values
299
+ });
300
+ }
301
+ kept.set(collection.name, list);
302
+ }
303
+ settle(form, kept, options.objects);
304
+ const layer = [["schema", form.schema]];
305
+ for (const collection of form.collections) {
306
+ const list = kept.get(collection.name) ?? [];
307
+ if (list.length === 0) continue;
308
+ layer.push([collection.name, list.map((record) => {
309
+ const item = [["id", record.id]];
310
+ if (record.anchor !== void 0) item.push(["anchor", record.anchor]);
311
+ for (const field of collection.fields) {
312
+ const value = valueOf(record.values, field.name);
313
+ if (value !== void 0) item.push([field.name, value]);
314
+ }
315
+ return Object.fromEntries(item);
316
+ })]);
317
+ }
318
+ return Object.fromEntries(layer);
319
+ }
320
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
321
+ /**
322
+ * This function gives the records of a form from a layer. Give it a layer that its add-on read: the function does not examine the form of an anchor.
323
+ *
324
+ * The form does not keep these data, and `more` tells them:
325
+ *
326
+ * - a field of the layer or of a record that the form does not have
327
+ * - a record with no `id`, or with the `id` of an earlier record
328
+ * - a record of a collection with surfaces that has no anchor on one of them
329
+ * - a value that is not a valid value of its field
330
+ * - a field that names a record that the layer does not have
331
+ * - a record after the largest number of records of its owner
332
+ *
333
+ * The records of a layer of `formLayer` are the records that the layer has, and `more` is false for them.
334
+ */
335
+ function formRecords(form, layer) {
336
+ const kept = /* @__PURE__ */ new Map();
337
+ for (const collection of form.collections) kept.set(collection.name, []);
338
+ let more = false;
339
+ if (isObject(layer)) {
340
+ const names = new Set(form.collections.map((collection) => collection.name));
341
+ if (Object.keys(layer).some((key) => key !== "schema" && !names.has(key))) more = true;
342
+ const seen = /* @__PURE__ */ new Set();
343
+ for (const collection of form.collections) {
344
+ const given = Object.hasOwn(layer, collection.name) ? layer[collection.name] : void 0;
345
+ if (given === void 0) continue;
346
+ if (!Array.isArray(given)) {
347
+ more = true;
348
+ continue;
349
+ }
350
+ const known = /* @__PURE__ */ new Set([
351
+ "id",
352
+ ...collection.on === void 0 ? [] : ["anchor"],
353
+ ...collection.fields.map((field) => field.name)
354
+ ]);
355
+ const list = [];
356
+ for (const item of given) {
357
+ const id = isObject(item) ? item["id"] : void 0;
358
+ if (!isObject(item) || typeof id !== "string" || id === "" || seen.has(id)) {
359
+ more = true;
360
+ continue;
361
+ }
362
+ const anchor = item["anchor"];
363
+ const surfaces = collection.on ?? [];
364
+ if (collection.on !== void 0 && !(isObject(anchor) && typeof anchor["on"] === "string" && surfaces.includes(anchor["on"]))) {
365
+ more = true;
366
+ continue;
367
+ }
368
+ if (Object.keys(item).some((key) => !known.has(key))) more = true;
369
+ const values = [];
370
+ for (const field of collection.fields) {
371
+ const value = Object.hasOwn(item, field.name) ? item[field.name] : void 0;
372
+ if (value === void 0) continue;
373
+ if (field.kind === "number") {
374
+ if (typeof value === "number" && numberFits(field, value)) values.push([field.name, value]);
375
+ else more = true;
376
+ } else if (typeof value !== "string") more = true;
377
+ else if (field.kind === "text") {
378
+ if (value.trim() !== "") values.push([field.name, value.trim()]);
379
+ } else if (value === "") more = true;
380
+ else values.push([field.name, value]);
381
+ }
382
+ seen.add(id);
383
+ list.push({
384
+ id,
385
+ anchor: collection.on === void 0 ? void 0 : anchor,
386
+ values: Object.fromEntries(values)
387
+ });
388
+ }
389
+ kept.set(collection.name, list);
390
+ }
391
+ for (const collection of form.collections) {
392
+ const needed = collection.fields.filter((field) => field.needed === true);
393
+ const has = (record, field) => valueOf(record.values, field.name) !== void 0 || field.kind === "number" && field.usual !== void 0;
394
+ const list = (kept.get(collection.name) ?? []).filter((record) => needed.every((field) => has(record, field)));
395
+ if (list.length !== (kept.get(collection.name) ?? []).length) more = true;
396
+ kept.set(collection.name, list);
397
+ }
398
+ if (settle(form, kept, void 0)) more = true;
399
+ } else if (layer !== void 0) more = true;
400
+ const records = form.collections.map((collection) => [collection.name, (kept.get(collection.name) ?? []).map((record) => ({
401
+ id: record.id,
402
+ ...record.anchor === void 0 ? {} : { anchor: record.anchor },
403
+ values: record.values
404
+ }))]);
405
+ return {
406
+ records: Object.fromEntries(records),
407
+ more
408
+ };
409
+ }
410
+ export { ANCHOR_CODES, ANCHOR_SURFACES, CLOSURE_LIMIT, CONNECTION_FAULTS, CONNECTION_TURN_LIMIT, CONNECTION_USES, FINDING_CODES, FINDING_LEVELS, FLOOR_DEPTH, FORM_CODES, FORM_FIELD_KINDS, FORM_SYSTEMS, GLASS_THICKNESS, JOIN_TOLERANCE, LARGEST_LENGTH, LAYER_CODES, LENGTH_UNITS, LEVEL_SCHEMA, LEVEL_SHAPES, LOAD_LEVELS, MITER_LIMIT, NEAR_LIMIT, OPENING_KINDS, OUTLET_PLATE, RECORD_KINDS, ROOM_PLACES, ROOM_SCHEMA, SCENE_SCHEMA, SHAPE_OUTLINES, SOLID_KINDS, SQUARE_TURNS, SURVEY_SCHEMA, TO_Y_UP, WALL_FACES, WALL_SIDES, boundsOfSolids, checkAnchor, checkForm, checkLayers, checkRoom, checkScene, circuitStates, convertSurvey, expandLevel, expandSurvey, formLayer, formRecords, isLayerName, lengthsInRange, levelShape, metersPer, objectTransforms, outletLevels, parseRecordName, planShape, planShapes, readFormRecord, readLayer, recordName, roomSolids, sceneSolids, sceneSpace, shapeRing, solidCorners, solidRecord, solidVolume, unitsPer, wallFootprints, wallFrames, wallHasOutline, wallPoint, wallTransform };
74
411
 
75
412
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/plan.ts"],"sourcesContent":["import { transformPoint3, type Ring } from \"@mark1russell7/layout-contract\";\nimport type { Scene } from \"./room.ts\";\nimport { sceneSolids, type Solid, type SolidKind, type SolidOptions } from \"./solids.ts\";\n\n/** The outline of one solid in the plan of a room: the solid as a camera above the room sees it. */\nexport interface PlanShape {\n /** The `id` of the solid. */\n readonly solid: string;\n readonly kind: SolidKind;\n /** The `id` of the record that the solid comes from. */\n readonly source: string;\n /** The outline in the plan, in meters. */\n readonly ring: Ring;\n /** The height of the bottom of the solid above the floor, in meters. */\n readonly bottom: number;\n /** The height of the top of the solid above the floor, in meters. */\n readonly top: number;\n}\n\n/**\n * This function gives the outline of a solid in the plan.\n * Each box of a model stands on its bottom face, so the outline of a box is that face.\n */\nexport function planShape(solid: Solid): PlanShape {\n const { id, kind, source, shape } = solid;\n if (shape.kind === \"prism\") return { solid: id, kind, source, ring: shape.ring, bottom: shape.z, top: shape.z + shape.d };\n const { box, transform } = shape;\n const face = [\n { x: box.x, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y + box.h, z: box.z },\n { x: box.x, y: box.y + box.h, z: box.z },\n ].map((corner) => transformPoint3(transform, corner));\n const bottom = face[0]!.z;\n const top = transformPoint3(transform, { x: box.x, y: box.y, z: box.z + box.d }).z;\n return { solid: id, kind, source, ring: face.map((corner) => [corner.x, corner.y] as const), bottom: Math.min(bottom, top), top: Math.max(bottom, top) };\n}\n\n/** The options of a plan. */\nexport interface PlanOptions extends SolidOptions {\n /**\n * The height of the cut of the plan above the floor, in meters. The plan has only the solids with a bottom below the cut.\n * Thus a cut below the top of a door shows the door as a gap in its wall. Without a cut, the plan has each solid.\n */\n readonly cut?: number | undefined;\n}\n\n/**\n * This function gives the plan of a scene: the outline of each solid of its model.\n * The sequence goes from the solid with the lowest top to the solid with the highest top.\n * Thus a drawing in this sequence shows the room as a camera above it sees the room.\n */\nexport function planShapes(scene: Scene, options: PlanOptions = {}): readonly PlanShape[] {\n const cut = options.cut ?? Infinity;\n return sceneSolids(scene, options)\n .map((solid) => planShape(solid))\n .filter((shape) => shape.bottom < cut)\n .map((shape, index) => ({ shape, index }))\n .sort((a, b) => a.shape.top - b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AAS,GAAG,CAAC,CACrC,KAAK,OAAO,WAAW;EAAE;EAAO;CAAM,EAAE,CAAC,CACzC,MAAM,GAAG,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAC9D,KAAK,EAAE,YAAY,KAAK;AAC7B"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/plan.ts","../src/form.ts"],"sourcesContent":["import { transformPoint3, type Ring } from \"@mark1russell7/layout-contract\";\nimport type { Scene } from \"./room.ts\";\nimport { sceneSolids, type Solid, type SolidKind, type SolidOptions } from \"./solids.ts\";\n\n/** The outline of one solid in the plan of a room: the solid as a camera above the room sees it. */\nexport interface PlanShape {\n /** The `id` of the solid. */\n readonly solid: string;\n readonly kind: SolidKind;\n /** The `id` of the record that the solid comes from. */\n readonly source: string;\n /** The outline in the plan, in meters. */\n readonly ring: Ring;\n /** The height of the bottom of the solid above the floor, in meters. */\n readonly bottom: number;\n /** The height of the top of the solid above the floor, in meters. */\n readonly top: number;\n}\n\n/**\n * This function gives the outline of a solid in the plan.\n * Each box of a model stands on its bottom face, so the outline of a box is that face.\n */\nexport function planShape(solid: Solid): PlanShape {\n const { id, kind, source, shape } = solid;\n if (shape.kind === \"prism\") return { solid: id, kind, source, ring: shape.ring, bottom: shape.z, top: shape.z + shape.d };\n const { box, transform } = shape;\n const face = [\n { x: box.x, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y, z: box.z },\n { x: box.x + box.w, y: box.y + box.h, z: box.z },\n { x: box.x, y: box.y + box.h, z: box.z },\n ].map((corner) => transformPoint3(transform, corner));\n const bottom = face[0]!.z;\n const top = transformPoint3(transform, { x: box.x, y: box.y, z: box.z + box.d }).z;\n return { solid: id, kind, source, ring: face.map((corner) => [corner.x, corner.y] as const), bottom: Math.min(bottom, top), top: Math.max(bottom, top) };\n}\n\n/** The options of a plan. */\nexport interface PlanOptions extends SolidOptions {\n /**\n * The height of the cut of the plan above the floor, in meters. The plan has only the solids with a bottom below the cut.\n * Thus a cut below the top of a door shows the door as a gap in its wall. Without a cut, the plan has each solid.\n */\n readonly cut?: number | undefined;\n}\n\n/**\n * This function gives the plan of a scene: the outline of each solid of its model.\n * The sequence goes from the solid with the lowest top to the solid with the highest top.\n * Thus a drawing in this sequence shows the room as a camera above it sees the room.\n */\nexport function planShapes(scene: Scene, options: PlanOptions = {}): readonly PlanShape[] {\n const cut = options.cut ?? Infinity;\n return sceneSolids(scene, options)\n .map((solid) => planShape(solid))\n .filter((shape) => shape.bottom < cut)\n .map((shape, index) => ({ shape, index }))\n .sort((a, b) => a.shape.top - b.shape.top || a.index - b.index)\n .map(({ shape }) => shape);\n}\n","import type { Anchor, AnchorSurface } from \"./anchors.ts\";\nimport { isLayerName } from \"./room.ts\";\n\n// The form of a layer: the collections of its records and the fields of each record, as data.\n// A page makes the inputs of an add-on from this data, so the page has no code of a topic.\n// The functions of this file give a layer from the records of a form, and the records of a form from a layer.\n// A record of a layer has this shape: its `id`, its `anchor` when it has a place, and one value for each field.\n\n/** These are the systems of units of a person. A usual value has one number for each system. */\nexport const FORM_SYSTEMS: readonly [\"metric\", \"imperial\"] = [\"metric\", \"imperial\"];\n\n/** A system of units of a person. */\nexport type FormSystem = (typeof FORM_SYSTEMS)[number];\n\n/** The usual value of a number for each system of units. A page shows it in a field that has no value. */\nexport type FormUsual = Readonly<Record<FormSystem, number>>;\n\n/** These are the kinds of a field of a record. */\nexport const FORM_FIELD_KINDS: readonly [\"text\", \"number\", \"record\", \"object\"] = [\"text\", \"number\", \"record\", \"object\"];\n\n/** The kind of a field of a record. */\nexport type FormFieldKind = (typeof FORM_FIELD_KINDS)[number];\n\n/** The parts that each field of a record has. */\nexport interface FormFieldPart {\n /** The name of the field in a record of the layer, for example `breaker`. */\n readonly name: string;\n /** The name of the field in a page, for example `Breaker`. */\n readonly label: string;\n /** This value is true when a record needs a value of the field. A record with no value of it is not in the layer. */\n readonly needed?: boolean | undefined;\n}\n\n/** A field with a text, for example the name of a circuit. */\nexport interface FormTextField extends FormFieldPart {\n readonly kind: \"text\";\n}\n\n/** A field with a number in a fixed unit, for example the rating of a breaker in amperes. */\nexport interface FormNumberField extends FormFieldPart {\n readonly kind: \"number\";\n /** The text of the unit in a page, for example `A`. */\n readonly unit?: string | undefined;\n /** The value of a record that has no value of the field. */\n readonly usual?: FormUsual | undefined;\n /** A valid value is above this number. */\n readonly above?: number | undefined;\n /** A valid value is this number or more. */\n readonly least?: number | undefined;\n /** The sentence of a page for a value that is not valid. It tells the person the value to type. */\n readonly fault?: string | undefined;\n}\n\n/** A field with the `id` of a record of a collection of the same layer, for example the circuit of an outlet. */\nexport interface FormRecordField extends FormFieldPart {\n readonly kind: \"record\";\n /** The name of the collection of the record. */\n readonly of: string;\n /** The text of a page for no record, for example `No circuit`. */\n readonly none?: string | undefined;\n /** The sentence of help of a page when the collection has no record. It tells the way to the first record. */\n readonly aid?: string | undefined;\n}\n\n/** A field with the `id` of a placed object of the scene, for example the object of a power feed. */\nexport interface FormObjectField extends FormFieldPart {\n readonly kind: \"object\";\n}\n\n/** A field of a record of a form. */\nexport type FormField = FormTextField | FormNumberField | FormRecordField | FormObjectField;\n\n/**\n * A collection of a form: the records of one field of a layer, for example the circuits.\n *\n * - A collection with `on` has records with a place. A page shows them with the surface of their anchor.\n * - A collection with `owner` has records of an owner. A page shows them with their owner.\n * - Each other collection is a list of the level.\n */\nexport interface FormCollection {\n /** The name of the field of the layer that has the records, for example `circuits`. */\n readonly name: string;\n /** The word of one record for its `id`. For example, `circuit` gives the `id` `circuit-1`. */\n readonly word: string;\n /** The name of one record in a page, for example `Circuit`. */\n readonly label: string;\n /** The title of the records in a page, for example `Circuits`. */\n readonly title: string;\n /** The surfaces of the anchor of a record. A collection with no surfaces has records with no place. */\n readonly on?: readonly AnchorSurface[] | undefined;\n /** The usual height of a record on a wall above the floor, in meters. */\n readonly height?: FormUsual | undefined;\n /** The fields of a record, in the sequence of a page. */\n readonly fields: readonly FormField[];\n /** The name of the text field that gives the words of the `id` of a record. Without it, the `id` has the word and a number. */\n readonly idFrom?: string | undefined;\n /** The name of the field that names the owner of a record. It is a necessary field of the kind `object` or `record`. */\n readonly owner?: string | undefined;\n /** The largest number of records of one owner. */\n readonly most?: number | undefined;\n}\n\n/** The form of a layer. The add-on of the layer gives it as data. */\nexport interface LayerForm {\n /** The name of the format of the layer, for example `electrical/1`. */\n readonly schema: string;\n /** The collections of the layer, in the sequence of a page. */\n readonly collections: readonly FormCollection[];\n}\n\n/** These are the codes of the faults of a form. */\nexport const FORM_CODES: readonly [\"form-schema\", \"form-collection\", \"form-field\"] = [\"form-schema\", \"form-collection\", \"form-field\"];\n\n/** The code of a fault of a form. */\nexport type FormCode = (typeof FORM_CODES)[number];\n\n/** A fault of a form. */\nexport interface FormFault {\n readonly code: FormCode;\n /** The name of the collection, or the names of the collection and of the field with a point between them. For the form, it is empty. */\n readonly at: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n}\n\n/** The names that a field cannot have: the parts of each record, and a name that changes an object of JavaScript. */\nconst RESERVED: ReadonlySet<string> = new Set([\"id\", \"anchor\", \"__proto__\"]);\n\n/** This function tells if a number is a valid value of a number field. */\nfunction numberFits(field: FormNumberField, value: number): boolean {\n return Number.isFinite(value) && (field.above === undefined || value > field.above) && (field.least === undefined || value >= field.least);\n}\n\n/** This function gives the names that are in a list two times or more. */\nfunction repeated(names: readonly string[]): ReadonlySet<string> {\n const seen = new Set<string>();\n const twice = new Set<string>();\n for (const name of names) (seen.has(name) ? twice : seen).add(name);\n return twice;\n}\n\n/**\n * This function gives the faults of a form. A form with no fault is safe for `formLayer` and `formRecords`.\n * The test of an add-on examines its form with this function.\n */\nexport function checkForm(form: LayerForm): readonly FormFault[] {\n const faults: FormFault[] = [];\n if (!isLayerName(form.schema)) {\n faults.push({ code: \"form-schema\", at: \"\", message: `The form has the name \"${form.schema}\", which is not a word, a slash and a version, for example \"electrical/1\".` });\n }\n const names = new Set(form.collections.map((collection) => collection.name));\n const twice = repeated(form.collections.map((collection) => collection.name));\n for (const collection of form.collections) {\n const at = collection.name;\n const fault = (message: string): void => {\n faults.push({ code: \"form-collection\", at, message: `The collection \"${at}\" ${message}` });\n };\n if (at === \"\" || at === \"schema\" || at === \"__proto__\") fault(\"has a name that a layer cannot have.\");\n if (twice.has(at)) fault(\"is in the form two times.\");\n if (collection.word === \"\") fault(\"has no word for the ids of its records.\");\n if (collection.on !== undefined && (collection.on.length === 0 || repeated(collection.on).size > 0)) fault(\"has a list of surfaces that is empty, or that has a surface two times.\");\n if (collection.height !== undefined && !(collection.on ?? []).includes(\"wall\")) fault(\"has a usual height, and its records are not on a wall.\");\n if (collection.height !== undefined && !FORM_SYSTEMS.every((system) => Number.isFinite(collection.height?.[system]))) fault(\"has a usual height that is not a number.\");\n if (collection.most !== undefined && (!Number.isInteger(collection.most) || collection.most < 1)) fault(`has the largest number ${String(collection.most)}, which is not an integer of 1 or more.`);\n if (collection.most !== undefined && collection.owner === undefined) fault(\"has a largest number of records of one owner, and it has no owner.\");\n const fields = new Map(collection.fields.map((field) => [field.name, field]));\n if (collection.owner !== undefined) {\n const owner = fields.get(collection.owner);\n if (owner === undefined || owner.needed !== true || (owner.kind !== \"object\" && owner.kind !== \"record\")) {\n fault(`has the owner \"${collection.owner}\", which is not a necessary field of the kind \"object\" or \"record\".`);\n }\n }\n if (collection.idFrom !== undefined && fields.get(collection.idFrom)?.kind !== \"text\") fault(`takes its ids from \"${collection.idFrom}\", which is not a text field.`);\n const twiceFields = repeated(collection.fields.map((field) => field.name));\n for (const field of collection.fields) {\n const place = `${at}.${field.name}`;\n const fieldFault = (message: string): void => {\n faults.push({ code: \"form-field\", at: place, message: `The field \"${field.name}\" of the collection \"${at}\" ${message}` });\n };\n if (field.name === \"\" || RESERVED.has(field.name)) fieldFault(\"has a name that a field cannot have.\");\n if (twiceFields.has(field.name)) fieldFault(\"is in the collection two times.\");\n if (field.kind === \"record\" && !names.has(field.of)) fieldFault(`names the collection \"${field.of}\", which the form does not have.`);\n if (field.kind === \"number\") {\n if ((field.above !== undefined && !Number.isFinite(field.above)) || (field.least !== undefined && !Number.isFinite(field.least))) fieldFault(\"has a limit that is not a number.\");\n if (field.usual !== undefined && !FORM_SYSTEMS.every((system) => numberFits(field, field.usual?.[system] ?? Number.NaN))) fieldFault(\"has a usual value that is not a valid value.\");\n }\n }\n }\n return faults;\n}\n\n/** A value of a field: a text, a number, or the `id` of a record or of a placed object. */\nexport type FormValue = string | number;\n\n/** A record of a form: the values that a person gave. */\nexport interface FormRecord {\n readonly id: string;\n /** The place of the record, for a collection with surfaces. */\n readonly anchor?: Anchor | undefined;\n /** The value of each field, by the name of the field. A field with no value is absent. */\n readonly values: Readonly<Record<string, FormValue>>;\n}\n\n/** The records of a form, by the name of each collection. */\nexport type FormRecords = Readonly<Record<string, readonly FormRecord[]>>;\n\n/**\n * The read of a record: its valid values, or the first field that stops the record.\n * The state `empty` tells a necessary field with no value, and the state `bad` tells a value that is not valid. The field of the place is `anchor`.\n */\nexport type FormReading = { readonly state: \"ok\"; readonly values: Readonly<Record<string, FormValue>> } | { readonly state: \"empty\" | \"bad\"; readonly field: string };\n\n/** This function gives the value of a field in the values of a record. A field that the values do not have gives `undefined`. */\nfunction valueOf(values: Readonly<Record<string, FormValue>>, name: string): FormValue | undefined {\n return Object.hasOwn(values, name) ? values[name] : undefined;\n}\n\n/**\n * This function reads the values of a record of a collection.\n *\n * - A number field with no value gets its usual value for the system.\n * - A text loses the spaces at its ends. An empty text is no value.\n * - A number that is not valid, or a value of a different type, stops the record.\n * - A necessary field with no value stops the record. A collection with surfaces needs an anchor on one of them.\n *\n * The function does not examine if a record or an object of a field is there. `formLayer` examines it.\n */\nexport function readFormRecord(collection: FormCollection, record: FormRecord, system: FormSystem): FormReading {\n if (collection.on !== undefined) {\n if (record.anchor === undefined) return { state: \"empty\", field: \"anchor\" };\n if (!collection.on.includes(record.anchor.on)) return { state: \"bad\", field: \"anchor\" };\n }\n const values: [string, FormValue][] = [];\n for (const field of collection.fields) {\n const given = valueOf(record.values, field.name);\n if (field.kind === \"number\") {\n const value = given ?? field.usual?.[system];\n if (value === undefined) {\n if (field.needed === true) return { state: \"empty\", field: field.name };\n continue;\n }\n if (typeof value !== \"number\" || !numberFits(field, value)) return { state: \"bad\", field: field.name };\n values.push([field.name, value]);\n continue;\n }\n if (given !== undefined && typeof given !== \"string\") return { state: \"bad\", field: field.name };\n const text = field.kind === \"text\" ? (given ?? \"\").trim() : (given ?? \"\");\n if (text === \"\") {\n if (field.needed === true) return { state: \"empty\", field: field.name };\n continue;\n }\n values.push([field.name, text]);\n }\n return { state: \"ok\", values: Object.fromEntries(values) };\n}\n\n/** A record that a layer can have: its values are valid. */\ninterface Kept {\n readonly id: string;\n readonly anchor: Anchor | undefined;\n /** The values of the record. `settle` removes a value that names a record that is not there. */\n values: Readonly<Record<string, FormValue>>;\n}\n\n/**\n * This function removes each part that names a record or an object that is not there, one time. It gives true when it removed a part.\n *\n * - A field of a record that is not in its collection loses its value. A field of an object that is not in `objects` loses its value too.\n * - A record with no value of a necessary field goes away.\n * - A record after the largest number of records of its owner goes away.\n */\nfunction settleOnce(form: LayerForm, kept: Map<string, Kept[]>, objects: ReadonlySet<string> | undefined): boolean {\n let changed = false;\n const ids = new Map<string, ReadonlySet<string>>();\n for (const collection of form.collections) ids.set(collection.name, new Set((kept.get(collection.name) ?? []).map((record) => record.id)));\n for (const collection of form.collections) {\n const counts = new Map<string, number>();\n const list: Kept[] = [];\n for (const record of kept.get(collection.name) ?? []) {\n let stays = true;\n for (const field of collection.fields) {\n const value = valueOf(record.values, field.name);\n if (typeof value !== \"string\" || field.kind === \"text\" || field.kind === \"number\") continue;\n const there = field.kind === \"record\" ? ids.get(field.of)?.has(value) === true : objects === undefined || objects.has(value);\n if (there) continue;\n changed = true;\n if (field.needed === true) stays = false;\n else record.values = Object.fromEntries(Object.entries(record.values).filter(([name]) => name !== field.name));\n }\n if (stays && collection.owner !== undefined && collection.most !== undefined) {\n const owner = String(valueOf(record.values, collection.owner) ?? \"\");\n const count = (counts.get(owner) ?? 0) + 1;\n counts.set(owner, count);\n if (count > collection.most) {\n changed = true;\n stays = false;\n }\n }\n if (stays) list.push(record);\n }\n kept.set(collection.name, list);\n }\n return changed;\n}\n\n/**\n * This function removes each part that names a record or an object that is not there. It gives true when it removed a part.\n * A record that goes away can be the record of a field, so the function repeats `settleOnce` until nothing changes.\n */\nfunction settle(form: LayerForm, kept: Map<string, Kept[]>, objects: ReadonlySet<string> | undefined): boolean {\n let removed = false;\n while (settleOnce(form, kept, objects)) removed = true;\n return removed;\n}\n\n/** The options of `formLayer`. */\nexport interface FormLayerOptions {\n /** The system of units of the person, for the usual value of each number. */\n readonly system: FormSystem;\n /** The ids of the placed objects of the scene. With it, a field of the kind `object` keeps only an `id` of the set. */\n readonly objects?: ReadonlySet<string> | undefined;\n}\n\n/** A layer from the records of a form: its name, and the records of each collection that has records. */\nexport type FormLayer = Readonly<Record<string, unknown>> & { readonly schema: string };\n\n/**\n * This function makes the layer of the records of a form. It is total: a record that the layer cannot have is not in the layer.\n *\n * - `readFormRecord` reads each record. A record that it stops is not in the layer.\n * - The ids of a layer are unique. The first record of an `id` stays, in the sequence of the collections.\n * - A field that names a record that is not in the layer has no value. A record with no value of a necessary field is not in the layer.\n * - A collection with no record is not in the layer.\n *\n * A record of the layer has its `id`, then its `anchor`, then its values in the sequence of the fields. Thus equal records give equal JSON.\n * The add-on of the layer reads the result with its `parse`, and `checkLayers` examines it.\n */\nexport function formLayer(form: LayerForm, records: FormRecords, options: FormLayerOptions): FormLayer {\n const kept = new Map<string, Kept[]>();\n const seen = new Set<string>();\n for (const collection of form.collections) {\n const list: Kept[] = [];\n for (const record of Object.hasOwn(records, collection.name) ? (records[collection.name] ?? []) : []) {\n if (record.id === \"\" || seen.has(record.id)) continue;\n const reading = readFormRecord(collection, record, options.system);\n if (reading.state !== \"ok\") continue;\n seen.add(record.id);\n list.push({ id: record.id, anchor: collection.on === undefined ? undefined : record.anchor, values: reading.values });\n }\n kept.set(collection.name, list);\n }\n settle(form, kept, options.objects);\n const layer: [string, unknown][] = [[\"schema\", form.schema]];\n for (const collection of form.collections) {\n const list = kept.get(collection.name) ?? [];\n if (list.length === 0) continue;\n layer.push([\n collection.name,\n list.map((record) => {\n const item: [string, unknown][] = [[\"id\", record.id]];\n if (record.anchor !== undefined) item.push([\"anchor\", record.anchor]);\n for (const field of collection.fields) {\n const value = valueOf(record.values, field.name);\n if (value !== undefined) item.push([field.name, value]);\n }\n return Object.fromEntries(item);\n }),\n ]);\n }\n return Object.fromEntries(layer) as FormLayer;\n}\n\n/** The records of a form from a layer. */\nexport interface FormRecordsRead {\n /** The records of each collection of the form. A collection with no record has an empty list. */\n readonly records: FormRecords;\n /** This value is true when the layer has data that the form does not keep. */\n readonly more: boolean;\n}\n\nconst isObject = (value: unknown): value is Readonly<Record<string, unknown>> => typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/**\n * This function gives the records of a form from a layer. Give it a layer that its add-on read: the function does not examine the form of an anchor.\n *\n * The form does not keep these data, and `more` tells them:\n *\n * - a field of the layer or of a record that the form does not have\n * - a record with no `id`, or with the `id` of an earlier record\n * - a record of a collection with surfaces that has no anchor on one of them\n * - a value that is not a valid value of its field\n * - a field that names a record that the layer does not have\n * - a record after the largest number of records of its owner\n *\n * The records of a layer of `formLayer` are the records that the layer has, and `more` is false for them.\n */\nexport function formRecords(form: LayerForm, layer: unknown): FormRecordsRead {\n const kept = new Map<string, Kept[]>();\n for (const collection of form.collections) kept.set(collection.name, []);\n let more = false;\n if (isObject(layer)) {\n const names = new Set(form.collections.map((collection) => collection.name));\n if (Object.keys(layer).some((key) => key !== \"schema\" && !names.has(key))) more = true;\n const seen = new Set<string>();\n for (const collection of form.collections) {\n const given = Object.hasOwn(layer, collection.name) ? layer[collection.name] : undefined;\n if (given === undefined) continue;\n if (!Array.isArray(given)) {\n more = true;\n continue;\n }\n const known = new Set([\"id\", ...(collection.on === undefined ? [] : [\"anchor\"]), ...collection.fields.map((field) => field.name)]);\n const list: Kept[] = [];\n for (const item of given as readonly unknown[]) {\n const id = isObject(item) ? item[\"id\"] : undefined;\n if (!isObject(item) || typeof id !== \"string\" || id === \"\" || seen.has(id)) {\n more = true;\n continue;\n }\n const anchor = item[\"anchor\"];\n const surfaces: readonly string[] = collection.on ?? [];\n if (collection.on !== undefined && !(isObject(anchor) && typeof anchor[\"on\"] === \"string\" && surfaces.includes(anchor[\"on\"]))) {\n more = true;\n continue;\n }\n if (Object.keys(item).some((key) => !known.has(key))) more = true;\n const values: [string, FormValue][] = [];\n for (const field of collection.fields) {\n const value = Object.hasOwn(item, field.name) ? item[field.name] : undefined;\n if (value === undefined) continue;\n if (field.kind === \"number\") {\n if (typeof value === \"number\" && numberFits(field, value)) values.push([field.name, value]);\n else more = true;\n } else if (typeof value !== \"string\") more = true;\n else if (field.kind === \"text\") {\n // The spaces at the ends of a text are not data, and an empty text is no value.\n if (value.trim() !== \"\") values.push([field.name, value.trim()]);\n } else if (value === \"\") more = true;\n else values.push([field.name, value]);\n }\n seen.add(id);\n list.push({ id, anchor: collection.on === undefined ? undefined : (anchor as Anchor), values: Object.fromEntries(values) });\n }\n kept.set(collection.name, list);\n }\n // A record with no value of a necessary field is not a record of the form.\n for (const collection of form.collections) {\n const needed = collection.fields.filter((field) => field.needed === true);\n // A number with a usual value has a value in each layer of `formLayer`, so it does not stop a record.\n const has = (record: Kept, field: FormField): boolean => valueOf(record.values, field.name) !== undefined || (field.kind === \"number\" && field.usual !== undefined);\n const list = (kept.get(collection.name) ?? []).filter((record) => needed.every((field) => has(record, field)));\n if (list.length !== (kept.get(collection.name) ?? []).length) more = true;\n kept.set(collection.name, list);\n }\n if (settle(form, kept, undefined)) more = true;\n } else if (layer !== undefined) more = true;\n const records: [string, readonly FormRecord[]][] = form.collections.map((collection) => [\n collection.name,\n (kept.get(collection.name) ?? []).map((record): FormRecord => ({ id: record.id, ...(record.anchor === undefined ? {} : { anchor: record.anchor }), values: record.values })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GAAW,OAAO;CACvC,MAAM,UAA6C,KAAK,YAAY,KAAK,eAAe,CACtF,WAAW,OACV,KAAK,IAAI,WAAW,IAAI,KAAK,CAAC,EAAA,CAAG,KAAK,YAAwB;EAAE,IAAI,OAAO;EAAI,GAAI,OAAO,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,OAAO,OAAO;EAAI,QAAQ,OAAO;CAAO,EAAE,CAC7K,CAAC;CACD,OAAO;EAAE,SAAS,OAAO,YAAY,OAAO;EAAG;CAAK;AACtD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/room-view",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "description": "A room as data, and its 3D model from that data: walls with openings, floors, outlets, circuits and placed objects.",
6
6
  "license": "MIT",
7
7
  "repository": {