@nakafa/aksara-contracts 8.4.0 → 8.8.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/dist/assessment/document.d.ts +1 -1
- package/dist/assessment/document.js +1 -1
- package/dist/assessment/figure.d.ts +1 -1
- package/dist/assessment/figure.js +1 -1
- package/dist/assessment/fit.d.ts +3 -3
- package/dist/assessment/fit.js +3 -3
- package/dist/assessment/locales.d.ts +1 -1
- package/dist/assessment/scoring.d.ts +1 -1
- package/dist/assessment/scoring.js +1 -1
- package/dist/cache/content.d.ts +1 -1
- package/dist/cache/content.js +1 -1
- package/dist/content.d.ts +3 -2
- package/dist/graph/identity.d.ts +1 -1
- package/dist/graph/identity.js +1 -1
- package/dist/hash/sha256.d.ts +16 -0
- package/dist/hash/sha256.js +164 -0
- package/dist/hash/stream.d.ts +7 -5
- package/dist/hash/stream.js +13 -18
- package/dist/math/boundary.js +3 -22
- package/dist/math/bounds.d.ts +1 -1
- package/dist/math/collision.d.ts +1 -1
- package/dist/math/coordinate.d.ts +6 -5
- package/dist/math/coordinate.js +2 -2
- package/dist/math/edge.d.ts +11 -0
- package/dist/math/edge.js +74 -0
- package/dist/math/formula/compile.d.ts +1 -1
- package/dist/math/formula/compile.js +1 -1
- package/dist/math/formula/contour.d.ts +1 -1
- package/dist/math/formula/contour.js +1 -1
- package/dist/math/formula/field.js +1 -1
- package/dist/math/formula/mesh.d.ts +1 -1
- package/dist/math/formula/mesh.js +1 -1
- package/dist/math/formula/names.d.ts +1 -1
- package/dist/math/formula/names.js +1 -1
- package/dist/math/formula/parse.d.ts +1 -1
- package/dist/math/formula/parse.js +1 -1
- package/dist/math/formula/plane.d.ts +2 -2
- package/dist/math/formula/plane.js +3 -3
- package/dist/math/formula/reader.d.ts +2 -1
- package/dist/math/formula/reader.js +1 -1
- package/dist/math/formula/region.d.ts +2 -2
- package/dist/math/formula/region.js +3 -3
- package/dist/math/formula/sample.d.ts +1 -1
- package/dist/math/formula/scan.d.ts +1 -1
- package/dist/math/formula/scan.js +1 -1
- package/dist/math/formula/slider.d.ts +2 -2
- package/dist/math/formula/slider.js +1 -1
- package/dist/math/formula/space.d.ts +1 -1
- package/dist/math/formula/space.js +1 -1
- package/dist/math/graph.d.ts +9 -0
- package/dist/math/graph.js +66 -0
- package/dist/math/plane.js +6 -0
- package/dist/math/precision.d.ts +1 -1
- package/dist/math/precision.js +1 -1
- package/dist/math/resolution.js +1 -1
- package/dist/math/scene.d.ts +2 -2
- package/dist/math/shape.d.ts +392 -0
- package/dist/math/shape.js +59 -0
- package/dist/math/straight.d.ts +13 -0
- package/dist/math/straight.js +26 -0
- package/dist/math/vector.d.ts +1 -1
- package/dist/preview/spec.js +1 -1
- package/dist/program/curriculum.d.ts +1 -1
- package/dist/program/curriculum.js +1 -1
- package/dist/program/snapshot/digest.d.ts +1 -1
- package/dist/program/snapshot/digest.js +2 -2
- package/dist/program/snapshot/hash.d.ts +2 -2
- package/dist/projection/digest.d.ts +1 -1
- package/dist/projection/digest.js +1 -1
- package/dist/projection/hash.js +1 -1
- package/dist/projection/material.d.ts +1 -1
- package/dist/projection/material.js +1 -1
- package/dist/projection/verify.js +1 -1
- package/dist/quran/identity.d.ts +2 -1
- package/dist/quran/provenance.d.ts +2 -2
- package/dist/quran/provenance.js +1 -1
- package/dist/quran/snapshot/hash.d.ts +1 -1
- package/dist/quran/snapshot/row/hash.d.ts +1 -1
- package/dist/quran/snapshot/row/hash.js +1 -1
- package/dist/quran/snapshot/spec.js +1 -1
- package/dist/quran/source.d.ts +2 -2
- package/dist/release/current/evidence.d.ts +1 -1
- package/dist/release/current/evidence.js +1 -1
- package/dist/release/current/state.d.ts +1 -1
- package/dist/release/current/state.js +1 -1
- package/dist/release/head.js +1 -1
- package/dist/release/items.d.ts +1 -1
- package/dist/release/items.js +1 -1
- package/dist/release/policy.d.ts +1 -1
- package/dist/release/policy.js +1 -1
- package/dist/release/result/digest.d.ts +3 -3
- package/dist/release/result/digest.js +2 -2
- package/dist/release/rollback/digest.d.ts +1 -1
- package/dist/release/rollback/digest.js +1 -1
- package/dist/release/route/digest.d.ts +1 -1
- package/dist/release/route/digest.js +1 -1
- package/dist/release/snapshot/evidence/assessment.d.ts +1 -1
- package/dist/release/snapshot/evidence/assessment.js +1 -1
- package/dist/release/snapshot/evidence/program.d.ts +1 -1
- package/dist/release/snapshot/evidence/program.js +1 -1
- package/dist/release/snapshot/evidence/quran.d.ts +1 -1
- package/dist/release/snapshot/evidence/quran.js +1 -1
- package/dist/release/snapshot/evidence/requirement.d.ts +3 -2
- package/dist/release/snapshot/evidence/requirement.js +1 -1
- package/dist/release/snapshot/spec.d.ts +2 -2
- package/dist/release/snapshot/spec.js +1 -1
- package/dist/release/snapshot/verify.d.ts +1 -1
- package/dist/release/snapshot/verify.js +1 -1
- package/dist/release/spec.d.ts +1 -1
- package/dist/release/verify.d.ts +1 -1
- package/dist/release/verify.js +1 -1
- package/dist/renderer/compatibility.d.ts +1 -1
- package/dist/renderer/compatibility.js +2 -2
- package/dist/renderer/contract.d.ts +1 -1
- package/dist/renderer/contract.js +1 -1
- package/dist/runtime/spec.js +2 -2
- package/dist/signature/spec.d.ts +3 -2
- package/dist/signature/verify.d.ts +2 -1
- package/dist/transport/request.d.ts +1 -1
- package/dist/visual/base/math.d.ts +1 -1
- package/dist/visual/base/media.d.ts +1 -1
- package/dist/visual/biology/bacteria.d.ts +1 -1
- package/dist/visual/biology/bacteria.js +1 -1
- package/dist/visual/biology/blood.d.ts +91 -0
- package/dist/visual/biology/blood.js +55 -0
- package/dist/visual/biology/cell.d.ts +1 -1
- package/dist/visual/biology/climate.d.ts +1 -1
- package/dist/visual/biology/climate.js +1 -1
- package/dist/visual/biology/ecology.d.ts +1 -1
- package/dist/visual/biology/heart.d.ts +92 -0
- package/dist/visual/biology/heart.js +54 -0
- package/dist/visual/biology/mitochondrion.d.ts +91 -0
- package/dist/visual/biology/mitochondrion.js +45 -0
- package/dist/visual/biology/muscle.d.ts +103 -0
- package/dist/visual/biology/muscle.js +62 -0
- package/dist/visual/biology/neuron.d.ts +97 -0
- package/dist/visual/biology/neuron.js +48 -0
- package/dist/visual/biology/paddy.d.ts +100 -0
- package/dist/visual/biology/paddy.js +54 -0
- package/dist/visual/biology/physiology.d.ts +1 -1
- package/dist/visual/biology/physiology.js +1 -1
- package/dist/visual/biology/plant.d.ts +1 -1
- package/dist/visual/biology/plant.js +1 -1
- package/dist/visual/biology/synapse.d.ts +101 -0
- package/dist/visual/biology/synapse.js +46 -0
- package/dist/visual/biology/vessel.d.ts +104 -0
- package/dist/visual/biology/vessel.js +60 -0
- package/dist/visual/biology/yeast.d.ts +108 -0
- package/dist/visual/biology/yeast.js +61 -0
- package/dist/visual/biology.d.ts +1 -1
- package/dist/visual/catalog.d.ts +2177 -778
- package/dist/visual/catalog.js +28 -0
- package/dist/visual/chemistry/atom.d.ts +1 -1
- package/dist/visual/chemistry/atom.js +1 -1
- package/dist/visual/chemistry/balance.d.ts +1 -1
- package/dist/visual/chemistry/balance.js +1 -1
- package/dist/visual/chemistry/bonding.d.ts +1 -1
- package/dist/visual/chemistry/discovery.d.ts +1 -1
- package/dist/visual/chemistry/electrochemistry.d.ts +1 -1
- package/dist/visual/chemistry/electrochemistry.js +1 -1
- package/dist/visual/chemistry/electron.d.ts +1 -1
- package/dist/visual/chemistry/electron.js +1 -1
- package/dist/visual/chemistry/laws.d.ts +1 -1
- package/dist/visual/chemistry/laws.js +1 -1
- package/dist/visual/chemistry/particles.d.ts +1 -1
- package/dist/visual/chemistry/periodic.d.ts +1 -1
- package/dist/visual/chemistry/periodic.js +1 -1
- package/dist/visual/chemistry/rate.d.ts +1 -1
- package/dist/visual/chemistry/rate.js +1 -1
- package/dist/visual/chemistry/reaction.d.ts +1 -1
- package/dist/visual/chemistry/reaction.js +1 -1
- package/dist/visual/chemistry/titration.d.ts +1 -1
- package/dist/visual/chemistry/titration.js +1 -1
- package/dist/visual/mathematics/chance.d.ts +1 -1
- package/dist/visual/mathematics/chance.js +1 -1
- package/dist/visual/mathematics/chart.d.ts +1 -1
- package/dist/visual/mathematics/charts.d.ts +1 -1
- package/dist/visual/mathematics/function.d.ts +1 -1
- package/dist/visual/mathematics/journey.d.ts +118 -0
- package/dist/visual/mathematics/journey.js +125 -0
- package/dist/visual/mathematics/logic.d.ts +90 -0
- package/dist/visual/mathematics/logic.js +49 -0
- package/dist/visual/mathematics/network.d.ts +101 -0
- package/dist/visual/mathematics/network.js +97 -0
- package/dist/visual/mathematics/numeral.d.ts +82 -1
- package/dist/visual/mathematics/numeral.js +49 -1
- package/dist/visual/mathematics/sets.d.ts +92 -0
- package/dist/visual/mathematics/sets.js +95 -0
- package/dist/visual/physics/braking.d.ts +1 -1
- package/dist/visual/physics/braking.js +1 -1
- package/dist/visual/physics/circuit.d.ts +1 -1
- package/dist/visual/physics/circular.d.ts +1 -1
- package/dist/visual/physics/circular.js +1 -1
- package/dist/visual/physics/dynamics.d.ts +1 -1
- package/dist/visual/physics/dynamics.js +1 -1
- package/dist/visual/physics/efficiency.d.ts +1 -1
- package/dist/visual/physics/efficiency.js +1 -1
- package/dist/visual/physics/electronics.d.ts +1 -1
- package/dist/visual/physics/falling.d.ts +1 -1
- package/dist/visual/physics/falling.js +1 -1
- package/dist/visual/physics/field.d.ts +1 -1
- package/dist/visual/physics/fluid.d.ts +1 -1
- package/dist/visual/physics/fluid.js +1 -1
- package/dist/visual/physics/force.d.ts +1 -1
- package/dist/visual/physics/gravity.d.ts +1 -1
- package/dist/visual/physics/heat.d.ts +1 -1
- package/dist/visual/physics/heat.js +1 -1
- package/dist/visual/physics/instrument.d.ts +1 -1
- package/dist/visual/physics/light.d.ts +1 -1
- package/dist/visual/physics/light.js +1 -1
- package/dist/visual/physics/measurement.d.ts +1 -1
- package/dist/visual/physics/measurement.js +1 -1
- package/dist/visual/physics/motion.d.ts +1 -1
- package/dist/visual/physics/nuclear.d.ts +1 -1
- package/dist/visual/physics/parabolic.d.ts +1 -1
- package/dist/visual/physics/position.d.ts +1 -1
- package/dist/visual/physics/position.js +1 -1
- package/dist/visual/physics/power.d.ts +1 -1
- package/dist/visual/physics/power.js +1 -1
- package/dist/visual/physics/precision.d.ts +1 -1
- package/dist/visual/physics/precision.js +1 -1
- package/dist/visual/physics/product.d.ts +1 -1
- package/dist/visual/physics/reading.d.ts +1 -1
- package/dist/visual/physics/reading.js +1 -1
- package/dist/visual/physics/record.d.ts +1 -1
- package/dist/visual/physics/record.js +1 -1
- package/dist/visual/physics/relative.d.ts +1 -1
- package/dist/visual/physics/relative.js +1 -1
- package/dist/visual/physics/solar.d.ts +1 -1
- package/dist/visual/physics/solar.js +1 -1
- package/dist/visual/physics/thermodynamics.d.ts +117 -0
- package/dist/visual/physics/thermodynamics.js +95 -0
- package/dist/visual/physics/vector.d.ts +1 -1
- package/dist/visual/physics/vector.js +1 -1
- package/dist/visual/physics/velocity.d.ts +1 -1
- package/dist/visual/physics/wave.d.ts +1 -1
- package/dist/visual/politics.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { FigureNodeSchema } from "#contracts/assessment/figure";
|
|
3
|
-
import {
|
|
3
|
+
import type { InlineInteractionNode, InlineNode } from "#contracts/assessment/inline";
|
|
4
4
|
/**
|
|
5
5
|
* Deepest nesting a document may have, counting `doc` as level 1 and a text
|
|
6
6
|
* node as a level. Sixteen is the nesting that Convex allows in one stored
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Array as Arr, Predicate, Schema, SchemaTransformation } from "effect";
|
|
2
2
|
import { FigureNodeSchema, ImageSchema } from "#contracts/assessment/figure";
|
|
3
3
|
import { LocalIdSchema } from "#contracts/assessment/identity";
|
|
4
|
-
import { InlineContentSchema
|
|
4
|
+
import { InlineContentSchema } from "#contracts/assessment/inline";
|
|
5
5
|
import { LatexSchema, PlainTextSchema, PositiveIntSchema, } from "#contracts/assessment/scalar";
|
|
6
6
|
/**
|
|
7
7
|
* Deepest nesting a document may have, counting `doc` as level 1 and a text
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import type { AssessmentVisuals, VisualName } from "#contracts/visual/catalog";
|
|
3
3
|
/**
|
|
4
4
|
* One uploaded image. The text alternative is required, and the pixel size is
|
|
5
5
|
* required so a page can reserve the space before the file loads.
|
|
@@ -2,7 +2,7 @@ import { Array as Arr, Schema } from "effect";
|
|
|
2
2
|
import { AssetIdSchema } from "#contracts/assessment/identity";
|
|
3
3
|
import { RichTextSchema } from "#contracts/assessment/inline";
|
|
4
4
|
import { PlainTextSchema, PositiveIntSchema, } from "#contracts/assessment/scalar";
|
|
5
|
-
import { assessmentVisuals, FIGURE_NAMES
|
|
5
|
+
import { assessmentVisuals, FIGURE_NAMES } from "#contracts/visual/catalog";
|
|
6
6
|
/**
|
|
7
7
|
* One uploaded image. The text alternative is required, and the pixel size is
|
|
8
8
|
* required so a page can reserve the space before the file loads.
|
package/dist/assessment/fit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { AssessmentDocument } from "#contracts/assessment/document";
|
|
2
|
+
import type { Interaction } from "#contracts/assessment/interaction";
|
|
3
|
+
import type { ScoringOverride } from "#contracts/assessment/scoring";
|
|
4
4
|
/**
|
|
5
5
|
* Checks that the interactions of a version and its prompt agree: each
|
|
6
6
|
* interaction has its own identifier and sits in the prompt as its kind
|
package/dist/assessment/fit.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Array as Arr, HashSet } from "effect";
|
|
2
|
-
import { documentPlacements
|
|
2
|
+
import { documentPlacements } from "#contracts/assessment/document";
|
|
3
3
|
import { hasDistinctIds, hasUniqueIds } from "#contracts/assessment/identity";
|
|
4
|
-
import { canSitInText
|
|
5
|
-
import { supportsRule
|
|
4
|
+
import { canSitInText } from "#contracts/assessment/interaction";
|
|
5
|
+
import { supportsRule } from "#contracts/assessment/scoring";
|
|
6
6
|
/**
|
|
7
7
|
* Checks that the prompt places one interaction where its kind belongs: a
|
|
8
8
|
* field exactly once, in text or as a block; a gap match once for each gap, in
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Option } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import type { CatalogRow } from "#contracts/assessment/catalog";
|
|
3
3
|
import type { ActiveAppLocaleList } from "#contracts/locale";
|
|
4
4
|
/**
|
|
5
5
|
* Finds the first catalog row that is not served where its node is: each row
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import type { InteractionKind } from "#contracts/assessment/interaction";
|
|
3
3
|
/**
|
|
4
4
|
* All or nothing: category 1 for a fully correct answer and 0 for any other,
|
|
5
5
|
* so k is 1. It is `match_correct` of QTI response processing.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Array as Arr, Match, Option, Schema } from "effect";
|
|
2
2
|
import { hasUniqueIds, LocalIdSchema } from "#contracts/assessment/identity";
|
|
3
|
-
import { canSitInText
|
|
3
|
+
import { canSitInText } from "#contracts/assessment/interaction";
|
|
4
4
|
import { LocalizedTextSchema, NonNegativeIntSchema, PlainTextSchema, PositiveIntSchema, } from "#contracts/assessment/scalar";
|
|
5
5
|
/**
|
|
6
6
|
* All or nothing: category 1 for a fully correct answer and 0 for any other,
|
package/dist/cache/content.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import type { Sha256Hash } from "#contracts/ids";
|
|
3
3
|
/** Mutable publication dependencies owned by the signed source contracts. */
|
|
4
4
|
export declare const ContentCacheScopeSchema: Schema.Literals<readonly ["article", "material", "page", "assessment", "program", "quran"]>;
|
|
5
5
|
export type ContentCacheScope = typeof ContentCacheScopeSchema.Type;
|
package/dist/cache/content.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { ContentFamilySchema } from "#contracts/content";
|
|
3
|
-
import { ReleaseIdSchema, Sha256HashSchema
|
|
3
|
+
import { ReleaseIdSchema, Sha256HashSchema } from "#contracts/ids";
|
|
4
4
|
import { ContentSnapshotKindSchema } from "#contracts/release/snapshot/scope";
|
|
5
5
|
const ARTIFACT_CACHE_PREFIX = "content-artifact:";
|
|
6
6
|
const SCOPE_CACHE_PREFIX = "content-scope:";
|
package/dist/content.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { PublicPath } from "#contracts/ids";
|
|
3
|
+
import { Sha256HashSchema } from "#contracts/ids";
|
|
4
|
+
import type { AppLocale } from "#contracts/locale";
|
|
4
5
|
/** Published content families backed by real Aksara source registries. */
|
|
5
6
|
export declare const ContentFamilySchema: Schema.Literals<readonly ["article", "material", "page"]>;
|
|
6
7
|
export type ContentFamily = typeof ContentFamilySchema.Type;
|
package/dist/graph/identity.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import type { LearningGraphIdentity } from "#contracts/graph/spec";
|
|
3
3
|
/** Validated hierarchy segments required to derive one graph identity. */
|
|
4
4
|
export declare const LearningGraphSegmentsSchema: Schema.Struct<{
|
|
5
5
|
readonly appLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de", "ms"]>, "@NakafaAI/AksaraAppLocale">;
|
package/dist/graph/identity.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Array as Arr, Effect, Schema } from "effect";
|
|
2
|
-
import { LearningGraphIdentitySchema
|
|
2
|
+
import { LearningGraphIdentitySchema } from "#contracts/graph/spec";
|
|
3
3
|
import { AppLocaleSchema } from "#contracts/locale";
|
|
4
4
|
import { isLowerKebab } from "#contracts/text/syntax";
|
|
5
5
|
const LearningGraphSegmentSchema = Schema.String.pipe(Schema.check(Schema.makeFilter(isLowerKebab)));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Incremental SHA-256 (FIPS 180-4) over bytes added in pieces. It keeps one
|
|
3
|
+
* 64-byte block and the eight state words, so hashing a stream of any length
|
|
4
|
+
* needs constant memory, and its digest equals Web Crypto's digest of the
|
|
5
|
+
* same bytes joined.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Sha256 {
|
|
8
|
+
#private;
|
|
9
|
+
/** Adds the next bytes of the message. */
|
|
10
|
+
update(bytes: Uint8Array): void;
|
|
11
|
+
/**
|
|
12
|
+
* Pads the message, finishes the hash, and returns its 32 digest bytes. It is
|
|
13
|
+
* read once: the padding becomes part of the state.
|
|
14
|
+
*/
|
|
15
|
+
digest(): Uint8Array;
|
|
16
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// biome-ignore-all lint/suspicious/noBitwiseOperators: SHA-256 is defined on 32-bit words (FIPS 180-4), so its rotations, shifts, and logical functions are bitwise by definition.
|
|
2
|
+
/**
|
|
3
|
+
* Packs 32-bit words into a big-endian view, so every read of a word index is a
|
|
4
|
+
* number and the state view's bytes are the digest bytes.
|
|
5
|
+
*/
|
|
6
|
+
function wordView(words) {
|
|
7
|
+
const view = new DataView(new ArrayBuffer(words.length * 4));
|
|
8
|
+
let index = 0;
|
|
9
|
+
for (const word of words) {
|
|
10
|
+
view.setUint32(index * 4, word);
|
|
11
|
+
index += 1;
|
|
12
|
+
}
|
|
13
|
+
return view;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The 64 round constants of SHA-256: the first 32 bits of the fractional parts
|
|
17
|
+
* of the cube roots of the first 64 primes (FIPS 180-4, section 4.2.2).
|
|
18
|
+
*/
|
|
19
|
+
const ROUND_CONSTANTS = wordView([
|
|
20
|
+
0x42_8a_2f_98, 0x71_37_44_91, 0xb5_c0_fb_cf, 0xe9_b5_db_a5, 0x39_56_c2_5b,
|
|
21
|
+
0x59_f1_11_f1, 0x92_3f_82_a4, 0xab_1c_5e_d5, 0xd8_07_aa_98, 0x12_83_5b_01,
|
|
22
|
+
0x24_31_85_be, 0x55_0c_7d_c3, 0x72_be_5d_74, 0x80_de_b1_fe, 0x9b_dc_06_a7,
|
|
23
|
+
0xc1_9b_f1_74, 0xe4_9b_69_c1, 0xef_be_47_86, 0x0f_c1_9d_c6, 0x24_0c_a1_cc,
|
|
24
|
+
0x2d_e9_2c_6f, 0x4a_74_84_aa, 0x5c_b0_a9_dc, 0x76_f9_88_da, 0x98_3e_51_52,
|
|
25
|
+
0xa8_31_c6_6d, 0xb0_03_27_c8, 0xbf_59_7f_c7, 0xc6_e0_0b_f3, 0xd5_a7_91_47,
|
|
26
|
+
0x06_ca_63_51, 0x14_29_29_67, 0x27_b7_0a_85, 0x2e_1b_21_38, 0x4d_2c_6d_fc,
|
|
27
|
+
0x53_38_0d_13, 0x65_0a_73_54, 0x76_6a_0a_bb, 0x81_c2_c9_2e, 0x92_72_2c_85,
|
|
28
|
+
0xa2_bf_e8_a1, 0xa8_1a_66_4b, 0xc2_4b_8b_70, 0xc7_6c_51_a3, 0xd1_92_e8_19,
|
|
29
|
+
0xd6_99_06_24, 0xf4_0e_35_85, 0x10_6a_a0_70, 0x19_a4_c1_16, 0x1e_37_6c_08,
|
|
30
|
+
0x27_48_77_4c, 0x34_b0_bc_b5, 0x39_1c_0c_b3, 0x4e_d8_aa_4a, 0x5b_9c_ca_4f,
|
|
31
|
+
0x68_2e_6f_f3, 0x74_8f_82_ee, 0x78_a5_63_6f, 0x84_c8_78_14, 0x8c_c7_02_08,
|
|
32
|
+
0x90_be_ff_fa, 0xa4_50_6c_eb, 0xbe_f9_a3_f7, 0xc6_71_78_f2,
|
|
33
|
+
]);
|
|
34
|
+
/**
|
|
35
|
+
* The initial hash value: the first 32 bits of the fractional parts of the
|
|
36
|
+
* square roots of the first 8 primes (FIPS 180-4, section 5.3.3).
|
|
37
|
+
*/
|
|
38
|
+
const INITIAL_STATE = [
|
|
39
|
+
0x6a_09_e6_67, 0xbb_67_ae_85, 0x3c_6e_f3_72, 0xa5_4f_f5_3a, 0x51_0e_52_7f,
|
|
40
|
+
0x9b_05_68_8c, 0x1f_83_d9_ab, 0x5b_e0_cd_19,
|
|
41
|
+
];
|
|
42
|
+
const BLOCK_BYTES = 64;
|
|
43
|
+
const LENGTH_BYTES = 8;
|
|
44
|
+
/** Rotates a 32-bit word right. */
|
|
45
|
+
function rotateRight(word, bits) {
|
|
46
|
+
return (word >>> bits) | (word << (32 - bits));
|
|
47
|
+
}
|
|
48
|
+
/** Reads the 32-bit big-endian word at a word index of a view. */
|
|
49
|
+
function wordAt(view, index) {
|
|
50
|
+
return view.getUint32(index * 4);
|
|
51
|
+
}
|
|
52
|
+
/** Writes the 32-bit big-endian word at a word index of a view. */
|
|
53
|
+
function setWord(view, index, word) {
|
|
54
|
+
view.setUint32(index * 4, word);
|
|
55
|
+
}
|
|
56
|
+
/** Expands one block into the 64-word message schedule (FIPS 180-4, 6.2.2 step 1). */
|
|
57
|
+
function expandSchedule(block, schedule) {
|
|
58
|
+
for (let index = 0; index < 16; index += 1) {
|
|
59
|
+
setWord(schedule, index, wordAt(block, index));
|
|
60
|
+
}
|
|
61
|
+
for (let index = 16; index < 64; index += 1) {
|
|
62
|
+
const early = wordAt(schedule, index - 15);
|
|
63
|
+
const late = wordAt(schedule, index - 2);
|
|
64
|
+
const sigma0 = rotateRight(early, 7) ^ rotateRight(early, 18) ^ (early >>> 3);
|
|
65
|
+
const sigma1 = rotateRight(late, 17) ^ rotateRight(late, 19) ^ (late >>> 10);
|
|
66
|
+
setWord(schedule, index, (wordAt(schedule, index - 16) +
|
|
67
|
+
sigma0 +
|
|
68
|
+
wordAt(schedule, index - 7) +
|
|
69
|
+
sigma1) >>>
|
|
70
|
+
0);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Runs the 64 rounds over the schedule and adds the result to the state (6.2.2 steps 2 to 4). */
|
|
74
|
+
function mixRounds(state, schedule) {
|
|
75
|
+
let a = wordAt(state, 0);
|
|
76
|
+
let b = wordAt(state, 1);
|
|
77
|
+
let c = wordAt(state, 2);
|
|
78
|
+
let d = wordAt(state, 3);
|
|
79
|
+
let e = wordAt(state, 4);
|
|
80
|
+
let f = wordAt(state, 5);
|
|
81
|
+
let g = wordAt(state, 6);
|
|
82
|
+
let h = wordAt(state, 7);
|
|
83
|
+
for (let index = 0; index < 64; index += 1) {
|
|
84
|
+
const sum1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
|
|
85
|
+
const choice = (e & f) ^ (~e & g);
|
|
86
|
+
const first = (h +
|
|
87
|
+
sum1 +
|
|
88
|
+
choice +
|
|
89
|
+
wordAt(ROUND_CONSTANTS, index) +
|
|
90
|
+
wordAt(schedule, index)) >>>
|
|
91
|
+
0;
|
|
92
|
+
const sum0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
|
|
93
|
+
const majority = (a & b) ^ (a & c) ^ (b & c);
|
|
94
|
+
h = g;
|
|
95
|
+
g = f;
|
|
96
|
+
f = e;
|
|
97
|
+
e = (d + first) >>> 0;
|
|
98
|
+
d = c;
|
|
99
|
+
c = b;
|
|
100
|
+
b = a;
|
|
101
|
+
a = (first + sum0 + majority) >>> 0;
|
|
102
|
+
}
|
|
103
|
+
setWord(state, 0, (wordAt(state, 0) + a) >>> 0);
|
|
104
|
+
setWord(state, 1, (wordAt(state, 1) + b) >>> 0);
|
|
105
|
+
setWord(state, 2, (wordAt(state, 2) + c) >>> 0);
|
|
106
|
+
setWord(state, 3, (wordAt(state, 3) + d) >>> 0);
|
|
107
|
+
setWord(state, 4, (wordAt(state, 4) + e) >>> 0);
|
|
108
|
+
setWord(state, 5, (wordAt(state, 5) + f) >>> 0);
|
|
109
|
+
setWord(state, 6, (wordAt(state, 6) + g) >>> 0);
|
|
110
|
+
setWord(state, 7, (wordAt(state, 7) + h) >>> 0);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Incremental SHA-256 (FIPS 180-4) over bytes added in pieces. It keeps one
|
|
114
|
+
* 64-byte block and the eight state words, so hashing a stream of any length
|
|
115
|
+
* needs constant memory, and its digest equals Web Crypto's digest of the
|
|
116
|
+
* same bytes joined.
|
|
117
|
+
*/
|
|
118
|
+
export class Sha256 {
|
|
119
|
+
#state = wordView(INITIAL_STATE);
|
|
120
|
+
#block = new Uint8Array(BLOCK_BYTES);
|
|
121
|
+
#blockView = new DataView(this.#block.buffer);
|
|
122
|
+
#schedule = new DataView(new ArrayBuffer(64 * 4));
|
|
123
|
+
#blockLength = 0;
|
|
124
|
+
#totalBytes = 0;
|
|
125
|
+
/** Adds the next bytes of the message. */
|
|
126
|
+
update(bytes) {
|
|
127
|
+
this.#totalBytes += bytes.byteLength;
|
|
128
|
+
let offset = 0;
|
|
129
|
+
while (offset < bytes.byteLength) {
|
|
130
|
+
const taken = Math.min(BLOCK_BYTES - this.#blockLength, bytes.byteLength - offset);
|
|
131
|
+
this.#block.set(bytes.subarray(offset, offset + taken), this.#blockLength);
|
|
132
|
+
this.#blockLength += taken;
|
|
133
|
+
offset += taken;
|
|
134
|
+
if (this.#blockLength === BLOCK_BYTES) {
|
|
135
|
+
this.#compress();
|
|
136
|
+
this.#blockLength = 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Pads the message, finishes the hash, and returns its 32 digest bytes. It is
|
|
142
|
+
* read once: the padding becomes part of the state.
|
|
143
|
+
*/
|
|
144
|
+
digest() {
|
|
145
|
+
const bitLength = this.#totalBytes * 8;
|
|
146
|
+
this.#block[this.#blockLength] = 0x80;
|
|
147
|
+
this.#blockLength += 1;
|
|
148
|
+
if (this.#blockLength > BLOCK_BYTES - LENGTH_BYTES) {
|
|
149
|
+
this.#block.fill(0, this.#blockLength);
|
|
150
|
+
this.#compress();
|
|
151
|
+
this.#blockLength = 0;
|
|
152
|
+
}
|
|
153
|
+
this.#block.fill(0, this.#blockLength);
|
|
154
|
+
this.#blockView.setUint32(BLOCK_BYTES - 8, Math.floor(bitLength / 2 ** 32));
|
|
155
|
+
this.#blockView.setUint32(BLOCK_BYTES - 4, bitLength >>> 0);
|
|
156
|
+
this.#compress();
|
|
157
|
+
return new Uint8Array(this.#state.buffer.slice(0));
|
|
158
|
+
}
|
|
159
|
+
/** Mixes the full 64-byte block into the state words. */
|
|
160
|
+
#compress() {
|
|
161
|
+
expandSchedule(this.#blockView, this.#schedule);
|
|
162
|
+
mixRounds(this.#state, this.#schedule);
|
|
163
|
+
}
|
|
164
|
+
}
|
package/dist/hash/stream.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Hashes one digest stream piece by piece. Each piece is encoded to UTF-8 on its
|
|
4
|
+
* own, so a lone surrogate keeps the bytes it always had, and the running
|
|
5
|
+
* SHA-256 keeps memory constant however long the stream grows: a snapshot proof
|
|
6
|
+
* over a hundred megabytes of rows never holds those bytes at once.
|
|
5
7
|
*/
|
|
6
8
|
export declare class DigestStream {
|
|
7
9
|
#private;
|
|
8
10
|
/** Appends one piece of text in the order the stream was built. */
|
|
9
11
|
add(text: string): void;
|
|
10
|
-
/**
|
|
11
|
-
digest():
|
|
12
|
+
/** Finishes the stream once and returns its branded sha256 identity. */
|
|
13
|
+
digest(): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
|
|
12
14
|
}
|
package/dist/hash/stream.js
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Hex } from "effect/encoding";
|
|
3
|
+
import { Sha256 } from "#contracts/hash/sha256";
|
|
4
|
+
import { Sha256HashSchema } from "#contracts/ids";
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* Hashes one digest stream piece by piece. Each piece is encoded to UTF-8 on its
|
|
7
|
+
* own, so a lone surrogate keeps the bytes it always had, and the running
|
|
8
|
+
* SHA-256 keeps memory constant however long the stream grows: a snapshot proof
|
|
9
|
+
* over a hundred megabytes of rows never holds those bytes at once.
|
|
7
10
|
*/
|
|
8
11
|
export class DigestStream {
|
|
9
|
-
#
|
|
10
|
-
#
|
|
12
|
+
#hash = new Sha256();
|
|
13
|
+
#encoder = new TextEncoder();
|
|
11
14
|
/** Appends one piece of text in the order the stream was built. */
|
|
12
15
|
add(text) {
|
|
13
|
-
|
|
14
|
-
MutableList.append(this.#pieces, bytes);
|
|
15
|
-
this.#length += bytes.byteLength;
|
|
16
|
+
this.#hash.update(this.#encoder.encode(text));
|
|
16
17
|
}
|
|
17
|
-
/**
|
|
18
|
+
/** Finishes the stream once and returns its branded sha256 identity. */
|
|
18
19
|
digest() {
|
|
19
|
-
|
|
20
|
-
let offset = 0;
|
|
21
|
-
for (const piece of MutableList.toArray(this.#pieces)) {
|
|
22
|
-
bytes.set(piece, offset);
|
|
23
|
-
offset += piece.byteLength;
|
|
24
|
-
}
|
|
25
|
-
return hashBytes(bytes);
|
|
20
|
+
return Effect.sync(() => Sha256HashSchema.make(`sha256:${Hex.encode(this.#hash.digest())}`));
|
|
26
21
|
}
|
|
27
22
|
}
|
package/dist/math/boundary.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Array as Arr,
|
|
1
|
+
import { Array as Arr, Option, Result, Schema } from "effect";
|
|
2
2
|
import { readAffine } from "#contracts/math/formula/affine";
|
|
3
|
-
import {
|
|
3
|
+
import { readRelation } from "#contracts/math/formula/parse";
|
|
4
|
+
import { straightPoints } from "#contracts/math/straight";
|
|
4
5
|
/**
|
|
5
6
|
* How far from a boundary line a point may lie and still stand on it, relative
|
|
6
7
|
* to the size of the line's terms there: room for the rounding of decimal
|
|
@@ -33,26 +34,6 @@ function onLine({ a, b, c }, { x, y }) {
|
|
|
33
34
|
const size = Math.abs(a * x) + Math.abs(b * y) + Math.abs(c);
|
|
34
35
|
return Math.abs(value) <= ON_LINE_TOLERANCE * Math.max(1, size);
|
|
35
36
|
}
|
|
36
|
-
/** Two points of a graph that is a straight line: an affine formula in its input axis. */
|
|
37
|
-
function straightGraph(formula, input) {
|
|
38
|
-
return Result.getSuccess(readFormula(formula)).pipe(Option.flatMap((node) => readAffine(node, [input])), Option.map(({ constant, terms }) => {
|
|
39
|
-
const slope = terms[input] ?? 0;
|
|
40
|
-
/** The graph's point at one value of its input. */
|
|
41
|
-
const at = (value) => input === "x"
|
|
42
|
-
? { x: value, y: slope * value + constant }
|
|
43
|
-
: { x: slope * value + constant, y: value };
|
|
44
|
-
return [at(0), at(1)];
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
/** Two points of a straight object: a line, ray, segment or straight graph. */
|
|
48
|
-
function straightPoints(object) {
|
|
49
|
-
return Match.value(object).pipe(Match.discriminators("kind")({
|
|
50
|
-
function: ({ formula, inputAxis = "x" }) => straightGraph(formula, inputAxis),
|
|
51
|
-
line: ({ through }) => Option.some(through),
|
|
52
|
-
ray: ({ from, through }) => Option.some([from, through]),
|
|
53
|
-
segment: ({ from, to }) => Option.some([from, to]),
|
|
54
|
-
}), Match.orElse(() => Option.none()));
|
|
55
|
-
}
|
|
56
37
|
/** Two points of a straight object drawn solid, which a strict boundary may not hold. */
|
|
57
38
|
function solidStraight(object) {
|
|
58
39
|
return "stroke" in object && object.stroke !== undefined
|
package/dist/math/bounds.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Schema } from "effect";
|
|
2
2
|
import type { FormulaScope } from "#contracts/math/formula/compile";
|
|
3
3
|
import type { PlaneLabelAnchor, PlaneMathFrame, PlaneMathObject } from "#contracts/math/plane";
|
|
4
4
|
import type { SpaceLabelAnchor, SpaceMathFrame, SpaceMathObject, SpaceMathView } from "#contracts/math/space";
|
package/dist/math/collision.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BigDecimal } from "effect";
|
|
2
2
|
import type { SceneCoordinate } from "#contracts/math/coordinate";
|
|
3
3
|
import type { PlaneMathObject } from "#contracts/math/plane";
|
|
4
4
|
/** Finds reportable scene coordinates that collapse on the same axis. */
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { BigDecimal } from "effect";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import type { PlanePoint, SceneAxis, SpacePoint } from "#contracts/math/base";
|
|
4
|
+
import type { InfinitePathKind } from "#contracts/math/intersection";
|
|
4
5
|
import type { PlaneMathFrame } from "#contracts/math/plane";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import type { RenderThreshold } from "#contracts/math/precision";
|
|
7
|
+
import type { ExactRatio } from "#contracts/math/rational";
|
|
7
8
|
import type { SpaceMathFrame } from "#contracts/math/space";
|
|
8
9
|
export declare const ScenePathSchema: Schema.mutable<Schema.$Array<Schema.Union<readonly [Schema.Finite, Schema.String]>>>;
|
|
9
10
|
export type ScenePath = typeof ScenePathSchema.Type;
|
package/dist/math/coordinate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Array as Arr, Schema } from "effect";
|
|
2
|
-
import { SceneAxisSchema
|
|
2
|
+
import { SceneAxisSchema } from "#contracts/math/base";
|
|
3
3
|
import { AxisTraversalSchema, infinitePathInterval, } from "#contracts/math/intersection";
|
|
4
|
-
import { visiblePathResolvable
|
|
4
|
+
import { visiblePathResolvable } from "#contracts/math/precision";
|
|
5
5
|
import { affineRatio, ExactRatioSchema, numberRatio, } from "#contracts/math/rational";
|
|
6
6
|
export const ScenePathSchema = Schema.mutable(Schema.Array(Schema.Union([Schema.Finite, Schema.String])));
|
|
7
7
|
/** One ordered exact coordinate projected from a complete visual scene. */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Schema } from "effect";
|
|
2
|
+
import type { PlaneMathFrame, PlaneMathObject } from "#contracts/math/plane";
|
|
3
|
+
/**
|
|
4
|
+
* Guardrail G2: a polygon cut out by the scene's lines, with an edge along a
|
|
5
|
+
* line or a straight graph, may not close along the frame. The frame only says
|
|
6
|
+
* where the reader looks first and the plane continues past it, so an edge
|
|
7
|
+
* near a side of the frame that lies on no line, ray, segment, graph or axis
|
|
8
|
+
* is invented: it turns an open region into a closed one. Such a part of the
|
|
9
|
+
* plane is a `region` of inequalities, which continues past the frame.
|
|
10
|
+
*/
|
|
11
|
+
export declare function inventedEdgeIssues(frame: PlaneMathFrame, objects: readonly PlaneMathObject[]): readonly Schema.FilterIssue[];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Array as Arr, BigDecimal, Option } from "effect";
|
|
2
|
+
import { decimal } from "#contracts/math/rational";
|
|
3
|
+
import { straightPoints } from "#contracts/math/straight";
|
|
4
|
+
/** The x axis and the y axis, which every plane scene draws. */
|
|
5
|
+
const AXES = [
|
|
6
|
+
[
|
|
7
|
+
{ x: 0, y: 0 },
|
|
8
|
+
{ x: 1, y: 0 },
|
|
9
|
+
],
|
|
10
|
+
[
|
|
11
|
+
{ x: 0, y: 0 },
|
|
12
|
+
{ x: 0, y: 1 },
|
|
13
|
+
],
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Whether a point stands exactly on a line, by the cross product of decimal
|
|
17
|
+
* coordinates: a corner at an authored approximation such as 3.33 is not on
|
|
18
|
+
* the line it approximates, so the rule never guesses.
|
|
19
|
+
*/
|
|
20
|
+
function onCarrier([from, through], point) {
|
|
21
|
+
const cross = BigDecimal.subtract(BigDecimal.multiply(BigDecimal.subtract(decimal(through.x), decimal(from.x)), BigDecimal.subtract(decimal(point.y), decimal(from.y))), BigDecimal.multiply(BigDecimal.subtract(decimal(through.y), decimal(from.y)), BigDecimal.subtract(decimal(point.x), decimal(from.x))));
|
|
22
|
+
return BigDecimal.isZero(cross);
|
|
23
|
+
}
|
|
24
|
+
/** The edges of a polygon, the last one closing it back to its first corner. */
|
|
25
|
+
function edges(vertices) {
|
|
26
|
+
return Arr.zip(vertices, [
|
|
27
|
+
...Arr.drop(vertices, 1),
|
|
28
|
+
...Arr.take(vertices, 1),
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* How close to a side of the frame, as a share of the frame's width or
|
|
33
|
+
* height, an edge stands when it closes a shape where the frame happens to
|
|
34
|
+
* end: authors cut an open region at the frame or just inside its padding.
|
|
35
|
+
*/
|
|
36
|
+
const SIDE_BAND = 0.1;
|
|
37
|
+
/** Whether an edge runs along a side of the frame, within its band. */
|
|
38
|
+
function alongSide({ x, y }, [from, to]) {
|
|
39
|
+
const width = (x.max - x.min) * SIDE_BAND;
|
|
40
|
+
const height = (y.max - y.min) * SIDE_BAND;
|
|
41
|
+
return ((from.x <= x.min + width && to.x <= x.min + width) ||
|
|
42
|
+
(from.x >= x.max - width && to.x >= x.max - width) ||
|
|
43
|
+
(from.y <= y.min + height && to.y <= y.min + height) ||
|
|
44
|
+
(from.y >= y.max - height && to.y >= y.max - height));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Guardrail G2: a polygon cut out by the scene's lines, with an edge along a
|
|
48
|
+
* line or a straight graph, may not close along the frame. The frame only says
|
|
49
|
+
* where the reader looks first and the plane continues past it, so an edge
|
|
50
|
+
* near a side of the frame that lies on no line, ray, segment, graph or axis
|
|
51
|
+
* is invented: it turns an open region into a closed one. Such a part of the
|
|
52
|
+
* plane is a `region` of inequalities, which continues past the frame.
|
|
53
|
+
*/
|
|
54
|
+
export function inventedEdgeIssues(frame, objects) {
|
|
55
|
+
const carriers = [...Arr.getSomes(Arr.map(objects, straightPoints)), ...AXES];
|
|
56
|
+
// The lines that cut the plane without end: lines and straight graphs.
|
|
57
|
+
const cuts = Arr.getSomes(Arr.map(objects, (object) => object.kind === "line" || object.kind === "function"
|
|
58
|
+
? straightPoints(object)
|
|
59
|
+
: Option.none()));
|
|
60
|
+
/** Whether an edge lies along one of some lines. */
|
|
61
|
+
const along = (lines, [from, to]) => Arr.some(lines, (line) => onCarrier(line, from) && onCarrier(line, to));
|
|
62
|
+
return Arr.flatMap(objects, (object, index) => object.kind === "polygon" &&
|
|
63
|
+
Arr.some(edges(object.vertices), (edge) => along(cuts, edge))
|
|
64
|
+
? Arr.findFirst(edges(object.vertices), (edge) => alongSide(frame, edge) && !along(carriers, edge)).pipe(Option.match({
|
|
65
|
+
onNone: () => [],
|
|
66
|
+
onSome: ([from, to]) => [
|
|
67
|
+
{
|
|
68
|
+
issue: `Expected the polygon "${object.id}" to close only along lines of the scene; its edge from (${from.x}, ${from.y}) to (${to.x}, ${to.y}) runs along the frame's edge and lies on no line, ray, segment, graph or axis, so it closes an open region with an invented edge. Draw it as { kind: "region", inequalities: [...] }, which continues past the frame, and bound it only where the mathematics does, such as x <= 7 for an area up to 7.`,
|
|
69
|
+
path: ["objects", index],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
}))
|
|
73
|
+
: []);
|
|
74
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FormulaNode } from "#contracts/math/formula/syntax";
|
|
2
2
|
/** The value of every variable and parameter a formula reads, by name. */
|
|
3
3
|
export type FormulaScope = Readonly<Record<string, number>>;
|
|
4
4
|
/** A compiled formula: its value for one scope, or NaN where it is undefined. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Array as Arr } from "effect";
|
|
2
|
-
import { FORMULA_CONSTANTS
|
|
2
|
+
import { FORMULA_CONSTANTS } from "#contracts/math/formula/syntax";
|
|
3
3
|
/** Odd root indexes tried for a negative base, so `x^(1/3)` is real for x < 0. */
|
|
4
4
|
const ODD_ROOTS = [3, 5, 7, 9, 11];
|
|
5
5
|
const ROOT_TOLERANCE = 1e-9;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SampleBox } from "#contracts/math/formula/box";
|
|
2
2
|
import type { SampleBranch } from "#contracts/math/formula/sample";
|
|
3
3
|
/** A field over the plane: its value at one point, NaN where it is undefined. */
|
|
4
4
|
export type SampleField = (x: number, y: number) => number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Array as Arr, MutableHashMap, MutableHashSet, MutableList, Option, Result, Schema, } from "effect";
|
|
2
|
-
import { SamplePointSchema
|
|
2
|
+
import { SamplePointSchema } from "#contracts/math/formula/box";
|
|
3
3
|
/** Cells per frame side, enough for a smooth outline at the largest card size. */
|
|
4
4
|
export const CONTOUR_CELLS = 240;
|
|
5
5
|
/** One grid corner: its key, its point, and the field's value there when defined. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Array as Arr, Result, Schema } from "effect";
|
|
2
2
|
import { MathVisualKeySchema } from "#contracts/math/base";
|
|
3
3
|
import { readFormula, readRelation } from "#contracts/math/formula/parse";
|
|
4
|
-
import { FormulaParameterNameSchema
|
|
4
|
+
import { FormulaParameterNameSchema } from "#contracts/math/formula/syntax";
|
|
5
5
|
/** Passes a formula that reads, or names the problem of one that does not. */
|
|
6
6
|
function readable(read) {
|
|
7
7
|
return (text) => Result.match(read(text), {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import type { SamplePoint, SampleRange } from "#contracts/math/formula/box";
|
|
3
3
|
/** Cells along each side of a sampled surface. */
|
|
4
4
|
export declare const MESH_CELLS = 96;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Array as Arr, Option, Schema } from "effect";
|
|
2
|
-
import { SamplePointSchema
|
|
2
|
+
import { SamplePointSchema } from "#contracts/math/formula/box";
|
|
3
3
|
/** Cells along each side of a sampled surface. */
|
|
4
4
|
export const MESH_CELLS = 96;
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { HashSet } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import type { FormulaNode } from "#contracts/math/formula/syntax";
|
|
3
3
|
/** Every variable and parameter a node reads; constants are left out. */
|
|
4
4
|
export declare function formulaNames(node: FormulaNode): HashSet.HashSet<string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Array as Arr, HashSet } from "effect";
|
|
2
|
-
import { FORMULA_CONSTANTS
|
|
2
|
+
import { FORMULA_CONSTANTS } from "#contracts/math/formula/syntax";
|
|
3
3
|
/** Every variable and parameter a node reads; constants are left out. */
|
|
4
4
|
export function formulaNames(node) {
|
|
5
5
|
if (node.kind === "number") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import type { FormulaError, FormulaNode } from "#contracts/math/formula/syntax";
|
|
3
3
|
/** Reads a formula that is one expression, such as `2x^2 - 3x + 1`. */
|
|
4
4
|
export declare function readFormula(text: string): Result.Result<FormulaNode, FormulaError>;
|
|
5
5
|
/** Reads one equation or inequality, such as `x^2 + y^2 = 4` or `y < 2x + 1`. */
|