@kerros/schema 0.0.0-stage → 0.1.0-rc.1
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/LICENSE +21 -0
- package/README.md +25 -2
- package/dist/index.js +3735 -0
- package/dist/index.js.map +1 -0
- package/dist/types/model/authoring.d.ts +38 -0
- package/dist/types/model/boundaries.d.ts +41 -0
- package/dist/types/model/coverage.d.ts +8 -0
- package/dist/types/model/document.d.ts +9 -0
- package/dist/types/model/factory.d.ts +5 -0
- package/dist/types/model/geometry.d.ts +99 -0
- package/dist/types/model/inference.d.ts +46 -0
- package/dist/types/model/live.d.ts +60 -0
- package/dist/types/model/materials.d.ts +28 -0
- package/dist/types/model/mutations.d.ts +178 -0
- package/dist/types/model/navigation.d.ts +70 -0
- package/dist/types/model/ontology.d.ts +43 -0
- package/dist/types/model/passages.d.ts +2 -0
- package/dist/types/model/portals.d.ts +9 -0
- package/dist/types/model/precision.d.ts +11 -0
- package/dist/types/model/project.d.ts +8 -0
- package/dist/types/model/roomNavigation.d.ts +15 -0
- package/dist/types/model/routeClearance.d.ts +11 -0
- package/dist/types/model/spaces.d.ts +46 -0
- package/dist/types/model/topology.d.ts +14 -0
- package/dist/types/model/types.d.ts +369 -0
- package/dist/types/model/validate.d.ts +38 -0
- package/dist/types/model/vertical.d.ts +145 -0
- package/dist/types/schema/index.d.ts +25 -0
- package/package.json +34 -4
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Floor, Point, ProjectDocument, Ring, SiteObject } from './types';
|
|
2
|
+
/** True for the kinds that connect levels. */
|
|
3
|
+
export declare const isVertical: (kind: string) => kind is "elevator" | "stairs";
|
|
4
|
+
/** Which shaft this object is part of.
|
|
5
|
+
*
|
|
6
|
+
* A shaft is one thing standing in one place reaching several levels, and that is how the document
|
|
7
|
+
* can describe it: one object, one position, one `servedFloorIds`. Older documents — the demo among
|
|
8
|
+
* them — instead repeat the object on every storey it serves, because that is what you had to do
|
|
9
|
+
* before anything read the served list. Both must draw as one lift, so a shaft is identified by what
|
|
10
|
+
* makes it the same shaft: its kind, its name, and where it stands. */
|
|
11
|
+
export declare const shaftKey: (object: SiteObject) => string;
|
|
12
|
+
/** Every level this shaft reaches, lowest first.
|
|
13
|
+
*
|
|
14
|
+
* `servedFloorIds` when it is authored — that is the document's own statement and outranks any
|
|
15
|
+
* inference. A shaft that declares nothing serves the floor it stands on and no other: better to
|
|
16
|
+
* draw a stair going nowhere, which is visibly wrong and easy to fix, than to invent a connection
|
|
17
|
+
* that routing would then happily send someone through. */
|
|
18
|
+
export declare function servedFloors(project: ProjectDocument, object: SiteObject): Floor[];
|
|
19
|
+
/** One climb between two levels the shaft serves. */
|
|
20
|
+
export interface Flight {
|
|
21
|
+
from: Floor;
|
|
22
|
+
to: Floor;
|
|
23
|
+
/** Metres climbed, always positive. */
|
|
24
|
+
rise: number;
|
|
25
|
+
}
|
|
26
|
+
/** The climbs this shaft makes, bottom first.
|
|
27
|
+
*
|
|
28
|
+
* Consecutive served levels, so a stair serving 0-1-2 makes two flights and a lift serving the same
|
|
29
|
+
* three makes two hops of shaft. A level in between that the shaft passes without stopping is simply
|
|
30
|
+
* not in the list, and the flight spanning it is the taller for it — which is the right picture: an
|
|
31
|
+
* express lift's shaft does pass those floors, and a spiral stair's helix does wind past a mezzanine
|
|
32
|
+
* it has no landing on. */
|
|
33
|
+
export declare function flights(project: ProjectDocument, object: SiteObject): Flight[];
|
|
34
|
+
/** Does this shaft reach the given level? Includes the floor it is filed under. */
|
|
35
|
+
export declare const reaches: (project: ProjectDocument, object: SiteObject, floorId: string | null) => boolean;
|
|
36
|
+
/** The flight arriving at a level from below, and the one leaving it upward — what you would see
|
|
37
|
+
* standing on that level. Either may be absent at the ends of the run. */
|
|
38
|
+
export declare function flightsAt(project: ProjectDocument, object: SiteObject, floorId: string | null): {
|
|
39
|
+
up?: Flight;
|
|
40
|
+
down?: Flight;
|
|
41
|
+
};
|
|
42
|
+
/** How far a shaft's body runs, as absolute elevations: the lowest level it serves to the highest.
|
|
43
|
+
* Null when it serves fewer than two levels and so has no body to speak of. */
|
|
44
|
+
export declare function span(project: ProjectDocument, object: SiteObject): {
|
|
45
|
+
bottom: number;
|
|
46
|
+
top: number;
|
|
47
|
+
} | null;
|
|
48
|
+
/** The angle a flight of this kind wants to climb at, in degrees from horizontal.
|
|
49
|
+
*
|
|
50
|
+
* An escalator is a machine built to one geometry: 30°, the world over. A stair is free-er but a
|
|
51
|
+
* comfortable flight is around 32°, and anything past about 42° is a ladder. These are what the
|
|
52
|
+
* plan should be *checked against* — the footprint stays the truth of where the thing is — so a run
|
|
53
|
+
* too short for its rise reads as the steep slope it would really be. */
|
|
54
|
+
export declare const PITCH: {
|
|
55
|
+
readonly escalator: 30;
|
|
56
|
+
readonly stairs: 32;
|
|
57
|
+
};
|
|
58
|
+
/** The run a flight of this rise needs to climb at its natural pitch. Use it to size a shaft the
|
|
59
|
+
* drawing has not sized, and to tell whether one it has sized is plausible. */
|
|
60
|
+
export declare const runFor: (rise: number, pitch?: number) => number;
|
|
61
|
+
/** The pitch a flight actually climbs at, given the run the plan gives it. */
|
|
62
|
+
export declare const pitchOf: (rise: number, run: number) => number;
|
|
63
|
+
/** The deepest tread that is still a tread. Past about a third of a metre a flight stops being a
|
|
64
|
+
* stair: the going grows with the box while the rise per step does not, and what you get is a ramp
|
|
65
|
+
* with slabs laid on it. A box longer than the climb needs keeps its length — the surplus is
|
|
66
|
+
* landing, which is what that spare floor really is. */
|
|
67
|
+
export declare const MAX_GOING = 0.32;
|
|
68
|
+
/** The treads one flight of this rise gets, and how deep each is in a run of this length. Capped
|
|
69
|
+
* both ways: a handful of boxes reads as a stair, two hundred reads as a stair and costs a level. */
|
|
70
|
+
export declare function treads(rise: number, run: number): {
|
|
71
|
+
steps: number;
|
|
72
|
+
going: number;
|
|
73
|
+
};
|
|
74
|
+
export type StairModel = NonNullable<SiteObject['stairModel']>;
|
|
75
|
+
/** How a shaft is built — as the document says, or as its own footprint implies.
|
|
76
|
+
*
|
|
77
|
+
* A footprint that cannot take the rise at a civil pitch is describing a stair that turns, which is
|
|
78
|
+
* what a short wide core box always is. Both the renderer and the plate it cuts its hole in have to
|
|
79
|
+
* agree about that, so the reading lives here rather than in either of them. */
|
|
80
|
+
export declare function stairModel(project: ProjectDocument, object: SiteObject): StairModel;
|
|
81
|
+
/** A bank of escalators is stacked criss-cross: every other flight runs the other way, so you step
|
|
82
|
+
* off one and turn to step onto the next. Which way round a given flight is decides which end of
|
|
83
|
+
* the footprint it arrives at, and so which end of it the floor above has to be open. */
|
|
84
|
+
export declare const flightReversed: (model: StairModel, index: number) => boolean;
|
|
85
|
+
/** Where one flight's sloping part actually lies inside the box the plan drew.
|
|
86
|
+
*
|
|
87
|
+
* The plan gives a footprint; the climb is what has to fit in it. An escalator keeps a metre of flat
|
|
88
|
+
* comb plate at each end and then climbs at the machine's own 30°, so a box with run to spare gets a
|
|
89
|
+
* longer landing at its foot instead of a shallower ramp — a 1.6 m rise in a 12 m box is a stair with
|
|
90
|
+
* a lot of floor round it, not a slide. A stair's treads are capped at MAX_GOING for the same reason.
|
|
91
|
+
* A box too short for its rise is left alone: it really is that steep and the picture should say so.
|
|
92
|
+
*
|
|
93
|
+
* `t` runs along the object's depth axis from its centre. The foot of a flight is at +depth/2 and its
|
|
94
|
+
* head at -depth/2, which is how the renderer has always laid one out; the surplus goes to whichever
|
|
95
|
+
* end that leaves free — the foot of an escalator, whose comb plates must stay at the ends the plan
|
|
96
|
+
* drew them at, and the head of a stair, which has none. */
|
|
97
|
+
export interface FlightRun {
|
|
98
|
+
/** The rotation this flight is drawn at — see flightReversed. */
|
|
99
|
+
rotation: number;
|
|
100
|
+
/** A point t metres along the run from the object's centre. */
|
|
101
|
+
at: (t: number) => Point;
|
|
102
|
+
/** How long the box is along that axis, and half of it. */
|
|
103
|
+
length: number;
|
|
104
|
+
half: number;
|
|
105
|
+
/** The flat plate at each end of an escalator; zero for a stair. */
|
|
106
|
+
pad: number;
|
|
107
|
+
/** The sloping part: how long it is, and where it starts and ends along the run. */
|
|
108
|
+
incline: number;
|
|
109
|
+
topT: number;
|
|
110
|
+
footT: number;
|
|
111
|
+
}
|
|
112
|
+
export declare function flightRun(project: ProjectDocument, object: SiteObject, rise: number, model: StairModel, index?: number): FlightRun;
|
|
113
|
+
/** The one twin that stands for the shaft: the lowest, so the flights count upward from the bottom.
|
|
114
|
+
* A shaft described the modern way — one object — is trivially its own primary. */
|
|
115
|
+
export declare function primaryShafts(project: ProjectDocument): Set<string>;
|
|
116
|
+
/** Does something come up through this level's floor? The shaft starts below it and reaches it or
|
|
117
|
+
* goes past — so a flight arrives here and the plate it arrives through has to be open.
|
|
118
|
+
*
|
|
119
|
+
* This is one half of what `passesThrough` used to answer for both. Requiring a served level above
|
|
120
|
+
* as well meant the flight arriving at the top of a run was drawn under an uncut slab: on Stockmann's
|
|
121
|
+
* ninth floor all twelve shafts arrive and not one of them cut a hole, so the last flight of every
|
|
122
|
+
* stair in the building was invisible from the storey it lands on. */
|
|
123
|
+
export declare function arrivesAt(project: ProjectDocument, object: SiteObject, floorId: string): boolean;
|
|
124
|
+
/** The other half: does something climb out through this level's ceiling? The shaft stands on this
|
|
125
|
+
* level or lower and carries on above it, so the lid a walked storey gets has to be open over it —
|
|
126
|
+
* which the bottom of a run needs just as much as the middle of one. */
|
|
127
|
+
export declare function departsFrom(project: ProjectDocument, object: SiteObject, floorId: string): boolean;
|
|
128
|
+
/** Does this shaft pass THROUGH a level — arriving from below and carrying on above? Both halves at
|
|
129
|
+
* once, which is the question a level in the middle of a run answers yes to and no end of one does. */
|
|
130
|
+
export declare const passesThrough: (project: ProjectDocument, object: SiteObject, floorId: string) => boolean;
|
|
131
|
+
export interface VoidOptions {
|
|
132
|
+
/** `floor` (the default) cuts what arrives from below; `ceiling` cuts what departs upward. */
|
|
133
|
+
through?: 'floor' | 'ceiling';
|
|
134
|
+
/** Ignore flights that set off below this elevation. An above-ground view draws nothing under
|
|
135
|
+
* grade, and a hole with nothing beneath it is worse than no hole at all. */
|
|
136
|
+
lowest?: number;
|
|
137
|
+
}
|
|
138
|
+
/** What to cut out of a level's floor plate, or out of the lid over a walked storey.
|
|
139
|
+
*
|
|
140
|
+
* A stairwell is a hole. Drawing the slab whole and the stair beneath it puts a lid over the flight,
|
|
141
|
+
* so from the landing above you see a plate where the opening should be and the stair appears to
|
|
142
|
+
* climb into the ceiling. The hole is only as big as the flight needs, though: a lift or a turning
|
|
143
|
+
* core is a shaft and takes its whole footprint, but a straight flight or an escalator lies under
|
|
144
|
+
* the floor for most of its length and wants opening only where it comes up — see headroomBand. */
|
|
145
|
+
export declare function shaftVoids(project: ProjectDocument, floorId: string, primary?: Set<string>, options?: VoidOptions): Ring[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type { ProjectDocument, ProjectSummary, Building, BuildingRoof, RoofSection, Floor, InteriorLight, LightFixture, Junction, VirtualBoundary, BoundaryUse, SpaceGeometry, Barrier, SiteObject, Drawing, Origin, Point, Ring, ObjectKind, Slope, MaterialKind, ModelKind, AssetRepository, NavNode, NavEdge, NavEdgeKind, Zone, Portal, PortalGroup, } from '../model/types';
|
|
2
|
+
export { spaces, spaceAt, spacePoint, inSpace } from '../model/spaces';
|
|
3
|
+
export { entryInto, perimeter, captive, zoneSpaces, addZone, removeZone, setZoneMembers, nestZone, addPortalGroup, removePortalGroup, setPortalGroupMembers, pruneOntology, } from '../model/ontology';
|
|
4
|
+
export { inferPortals, inferOpenBoundaries, refreshPortals, divideSpaces, spacesDividedBy, spacesRejoinedBy, mergeSpaces, } from '../model/inference';
|
|
5
|
+
export { derivedGraph } from '../model/topology';
|
|
6
|
+
export { sharedBoundaryPortals, effectivePortals } from '../model/portals';
|
|
7
|
+
export { isArea, isDevice, isOpening, isSpace, uid, OBJECT_KINDS } from '../model/types';
|
|
8
|
+
export { createObject, emptyProject } from '../model/factory';
|
|
9
|
+
export { enclosedRegion, enclosedRegions, refitEnclosedRooms } from '../model/spaces';
|
|
10
|
+
export { boundaryEdges, boundaryRegions, boundaryRegionAt, boundaryRings, derivedSpaceRings, bindSpaceToRegion, followsBoundaries, connectSpace, disconnectSpace, addVirtualBoundary, drawVirtualBoundary, addBoundaryHole, normalizeBoundaries, refreshBoundarySpaces, } from '../model/boundaries';
|
|
11
|
+
export type { BoundaryEdge, BoundaryRegion } from '../model/boundaries';
|
|
12
|
+
export { coverageOf, DEFAULT_RANGE, DEFAULT_FOV } from '../model/coverage';
|
|
13
|
+
export { copyProject, openingFloorId } from '../model/project';
|
|
14
|
+
export { MIN_SEGMENT, OPENING_MIN_SEGMENT, geoOrigin, moveOrigin, segmentsCross, toLngLat, toLocal, addBarrier, duplicateFloor, removeFloor, rectangle, rotate, centroid, distance, footprint, closeRing, openRing, ringArea, objectArea, pointInRing, objectPosition, objectRotation, barrierEnds, segmentProjection, slopeElevation, } from '../model/geometry';
|
|
15
|
+
export { exportProject, importProject, parseExport, blobDataUrl } from '../model/document';
|
|
16
|
+
export { validateProject, validateRelationships, validateRings, validateNavigation, transact, freezeProject, COORD_LIMIT, } from '../model/validate';
|
|
17
|
+
export type { TransactResult } from '../model/validate';
|
|
18
|
+
export { applyMutation, applyMutations } from '../model/mutations';
|
|
19
|
+
export type { Mutation, MutationOutcome, MutationResult } from '../model/mutations';
|
|
20
|
+
export { findRoute, navNodes, navEdges, HERE, routeSteps, routeAnchors, floorPhrase, addNavNode, addNavEdge, navPath, chainVertical, edgeCost, edgeLength, ELEVATOR_BASE, ELEVATOR_PER_METRE, STAIR_CLIMB_FACTOR, DOOR_COST, NAV_WELD, } from '../model/navigation';
|
|
21
|
+
export type { Route, RouteStep, RouteLeg, RouteOptions, RouteEnd, RoutePlace } from '../model/navigation';
|
|
22
|
+
export { EXTERIOR_PRESETS, type ExteriorPreset } from '../model/materials';
|
|
23
|
+
export { flights, flightsAt, isVertical, passesThrough, PITCH, pitchOf, primaryShafts, reaches, runFor, servedFloors, shaftKey, shaftVoids, span, type Flight, } from '../model/vertical';
|
|
24
|
+
export { buildRoomNavigation } from '../model/roomNavigation';
|
|
25
|
+
export type { RoomAccess, RoomNavigationGraph } from '../model/roomNavigation';
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerros/schema",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-rc.1",
|
|
4
|
+
"description": "Kerros floor-plan project schema: types, validation, portable import/export and indoor-navigation routing. Pure functions \u2014 no React, no rendering.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/kherrala/kerros.git",
|
|
10
|
+
"directory": "packages/schema"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/kherrala/kerros#readme",
|
|
13
|
+
"bugs": "https://github.com/kherrala/kerros/issues",
|
|
14
|
+
"keywords": ["floor-plan", "indoor-mapping", "routing", "typescript"],
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/types/schema/index.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/types/schema/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "vite build && tsc -p tsconfig.dts.json",
|
|
30
|
+
"prepack": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"registry": "https://registry.npmjs.org/"
|
|
35
|
+
}
|
|
36
|
+
}
|