@automovie/evidence 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -9
- package/lib/IAutoMovieDevelopmentProps.d.ts +7 -6
- package/lib/IAutoMovieEvidenceConfigProps.d.ts +9 -8
- package/lib/IAutoMovieNarrativeProps.d.ts +0 -3
- package/lib/IAutoMovieNoNarrativeProps.d.ts +16 -0
- package/lib/{narrative/IProductionLayerStages.js → IAutoMovieNoNarrativeProps.js} +1 -1
- package/lib/IAutoMovieNoNarrativeProps.js.map +1 -0
- package/lib/createDevelopmentContractClaims.d.ts +21 -11
- package/lib/createDevelopmentContractClaims.js +30 -13
- package/lib/createDevelopmentContractClaims.js.map +1 -1
- package/lib/createEvidenceConfig.d.ts +3 -3
- package/lib/createEvidenceConfig.js +19 -12
- package/lib/createEvidenceConfig.js.map +1 -1
- package/lib/index.d.ts +7 -8
- package/lib/index.js +1 -8
- package/lib/index.js.map +1 -1
- package/lib/internal/index.d.ts +5 -0
- package/lib/internal/index.js +7 -0
- package/lib/internal/index.js.map +1 -1
- package/lib/internal/resolveSkillsDirectory.d.ts +8 -9
- package/lib/internal/resolveSkillsDirectory.js +9 -12
- package/lib/internal/resolveSkillsDirectory.js.map +1 -1
- package/lib/narrative/IPackageChecklistClaimProps.d.ts +5 -10
- package/lib/narrative/IPackageContractProps.d.ts +0 -8
- package/lib/narrative/IPackagePopulationContractProps.d.ts +1 -9
- package/lib/narrative/IProductionConfigProps.d.ts +1 -10
- package/lib/narrative/createBriefFiles.d.ts +2 -2
- package/lib/narrative/createBriefFiles.js +2 -2
- package/lib/narrative/createNarrativeUnitFiles.d.ts +19 -12
- package/lib/narrative/createNarrativeUnitFiles.js +22 -17
- package/lib/narrative/createNarrativeUnitFiles.js.map +1 -1
- package/lib/narrative/createPackageChecklistClaim.js +5 -10
- package/lib/narrative/createPackageChecklistClaim.js.map +1 -1
- package/lib/narrative/createPackageContract.d.ts +3 -3
- package/lib/narrative/createPackageContract.js +3 -8
- package/lib/narrative/createPackageContract.js.map +1 -1
- package/lib/narrative/createPackagePopulationContract.d.ts +7 -7
- package/lib/narrative/createPackagePopulationContract.js +10 -18
- package/lib/narrative/createPackagePopulationContract.js.map +1 -1
- package/lib/narrative/index.d.ts +0 -4
- package/lib/narrative/index.js +0 -4
- package/lib/narrative/index.js.map +1 -1
- package/lib/narrative/internal/REALIZED_LAYERS.d.ts +1 -1
- package/lib/narrative/internal/REALIZED_LAYERS.js +1 -1
- package/lib/narrative/internal/claims/createDiscoveryClaim.d.ts +11 -3
- package/lib/narrative/internal/claims/createDiscoveryClaim.js +17 -5
- package/lib/narrative/internal/claims/createDiscoveryClaim.js.map +1 -1
- package/lib/narrative/internal/claims/createExpressionObligationClaims.d.ts +9 -8
- package/lib/narrative/internal/claims/createExpressionObligationClaims.js +15 -22
- package/lib/narrative/internal/claims/createExpressionObligationClaims.js.map +1 -1
- package/lib/narrative/internal/claims/createInstructionCoverageClaim.d.ts +6 -4
- package/lib/narrative/internal/claims/createInstructionCoverageClaim.js +7 -5
- package/lib/narrative/internal/claims/createInstructionCoverageClaim.js.map +1 -1
- package/lib/narrative/internal/claims/createLayerClaims.d.ts +9 -9
- package/lib/narrative/internal/claims/createLayerClaims.js +45 -65
- package/lib/narrative/internal/claims/createLayerClaims.js.map +1 -1
- package/lib/narrative/internal/claims/createOutlineClaims.js +8 -8
- package/lib/narrative/internal/claims/createOutlineClaims.js.map +1 -1
- package/lib/narrative/internal/claims/createPopulationObligationClaims.d.ts +3 -3
- package/lib/narrative/internal/claims/createPopulationObligationClaims.js +5 -5
- package/lib/narrative/internal/claims/createPopulationObligationClaims.js.map +1 -1
- package/lib/narrative/internal/claims/createReviewClaims.d.ts +8 -8
- package/lib/narrative/internal/claims/createReviewClaims.js +64 -77
- package/lib/narrative/internal/claims/createReviewClaims.js.map +1 -1
- package/lib/narrative/internal/claims/createSettingCoverageClaim.d.ts +1 -1
- package/lib/narrative/internal/claims/createSettingCoverageClaim.js +6 -7
- package/lib/narrative/internal/claims/createSettingCoverageClaim.js.map +1 -1
- package/lib/narrative/internal/collectProductionClaims.js +5 -2
- package/lib/narrative/internal/collectProductionClaims.js.map +1 -1
- package/lib/narrative/internal/index.d.ts +0 -1
- package/lib/narrative/internal/index.js +0 -1
- package/lib/narrative/internal/index.js.map +1 -1
- package/lib/narrative/internal/references/createCoverageReference.d.ts +1 -2
- package/lib/narrative/internal/references/createCoverageReference.js +2 -2
- package/lib/narrative/internal/references/createCoverageReference.js.map +1 -1
- package/lib/narrative/internal/references/createDiscoveryReferences.d.ts +2 -2
- package/lib/narrative/internal/references/createDiscoveryReferences.js +2 -2
- package/lib/narrative/internal/references/createLanguagePrincipleReferences.d.ts +7 -6
- package/lib/narrative/internal/references/createLanguagePrincipleReferences.js +7 -7
- package/lib/narrative/internal/references/createLanguagePrincipleReferences.js.map +1 -1
- package/lib/narrative/internal/references/createLineageReference.d.ts +7 -8
- package/lib/narrative/internal/references/createLineageReference.js +8 -8
- package/lib/narrative/internal/references/createLineageReference.js.map +1 -1
- package/lib/narrative/internal/references/createPrincipleReferences.d.ts +9 -8
- package/lib/narrative/internal/references/createPrincipleReferences.js +12 -12
- package/lib/narrative/internal/references/createPrincipleReferences.js.map +1 -1
- package/lib/narrative/internal/references/createSettingReferences.d.ts +3 -4
- package/lib/narrative/internal/references/createSettingReferences.js +6 -6
- package/lib/narrative/internal/references/createSettingReferences.js.map +1 -1
- package/lib/narrative/internal/references/layerFiles.d.ts +5 -5
- package/lib/narrative/internal/references/layerFiles.js +5 -5
- package/lib/narrative/internal/topology/createTopologyFiles.d.ts +1 -1
- package/lib/narrative/internal/topology/createTopologyFiles.js +1 -1
- package/lib/narrative/internal/utilities/BODY_ROOT.d.ts +15 -0
- package/lib/narrative/internal/utilities/BODY_ROOT.js +20 -0
- package/lib/narrative/internal/utilities/BODY_ROOT.js.map +1 -0
- package/lib/narrative/internal/utilities/PACKAGE_DOCS_ROOT.d.ts +6 -6
- package/lib/narrative/internal/utilities/PACKAGE_DOCS_ROOT.js +6 -6
- package/lib/narrative/internal/utilities/assertProductionEvidenceSources.js +6 -19
- package/lib/narrative/internal/utilities/assertProductionEvidenceSources.js.map +1 -1
- package/lib/narrative/internal/utilities/createUnitFiles.d.ts +4 -6
- package/lib/narrative/internal/utilities/createUnitFiles.js +5 -7
- package/lib/narrative/internal/utilities/createUnitFiles.js.map +1 -1
- package/lib/narrative/internal/utilities/index.d.ts +1 -1
- package/lib/narrative/internal/utilities/index.js +1 -1
- package/lib/narrative/internal/utilities/index.js.map +1 -1
- package/lib/narrative/internal/utilities/referenceLocation.d.ts +6 -9
- package/lib/narrative/internal/utilities/referenceLocation.js +9 -14
- package/lib/narrative/internal/utilities/referenceLocation.js.map +1 -1
- package/package.json +8 -4
- package/src/IAutoMovieDevelopmentProps.ts +7 -6
- package/src/IAutoMovieEvidenceConfigProps.ts +9 -8
- package/src/IAutoMovieNarrativeProps.ts +0 -4
- package/src/IAutoMovieNoNarrativeProps.ts +18 -0
- package/src/createDevelopmentContractClaims.ts +38 -14
- package/src/createEvidenceConfig.ts +23 -13
- package/src/index.ts +8 -8
- package/src/internal/index.ts +7 -0
- package/src/internal/resolveSkillsDirectory.ts +9 -12
- package/src/narrative/IPackageChecklistClaimProps.ts +5 -11
- package/src/narrative/IPackageContractProps.ts +0 -9
- package/src/narrative/IPackagePopulationContractProps.ts +1 -10
- package/src/narrative/IProductionConfigProps.ts +1 -11
- package/src/narrative/createBriefFiles.ts +2 -2
- package/src/narrative/createNarrativeUnitFiles.ts +28 -20
- package/src/narrative/createPackageChecklistClaim.ts +5 -10
- package/src/narrative/createPackageContract.ts +3 -15
- package/src/narrative/createPackagePopulationContract.ts +11 -26
- package/src/narrative/index.ts +0 -4
- package/src/narrative/internal/REALIZED_LAYERS.ts +1 -1
- package/src/narrative/internal/claims/createDiscoveryClaim.ts +20 -6
- package/src/narrative/internal/claims/createExpressionObligationClaims.ts +15 -24
- package/src/narrative/internal/claims/createInstructionCoverageClaim.ts +8 -6
- package/src/narrative/internal/claims/createLayerClaims.ts +48 -78
- package/src/narrative/internal/claims/createOutlineClaims.ts +8 -8
- package/src/narrative/internal/claims/createPopulationObligationClaims.ts +5 -5
- package/src/narrative/internal/claims/createReviewClaims.ts +69 -91
- package/src/narrative/internal/claims/createSettingCoverageClaim.ts +5 -7
- package/src/narrative/internal/collectProductionClaims.ts +7 -5
- package/src/narrative/internal/index.ts +0 -1
- package/src/narrative/internal/references/createCoverageReference.ts +1 -3
- package/src/narrative/internal/references/createDiscoveryReferences.ts +2 -2
- package/src/narrative/internal/references/createLanguagePrincipleReferences.ts +8 -9
- package/src/narrative/internal/references/createLineageReference.ts +7 -9
- package/src/narrative/internal/references/createPrincipleReferences.ts +13 -14
- package/src/narrative/internal/references/createSettingReferences.ts +5 -8
- package/src/narrative/internal/references/layerFiles.ts +5 -5
- package/src/narrative/internal/topology/createTopologyFiles.ts +1 -1
- package/src/narrative/internal/utilities/BODY_ROOT.ts +17 -0
- package/src/narrative/internal/utilities/PACKAGE_DOCS_ROOT.ts +6 -6
- package/src/narrative/internal/utilities/assertProductionEvidenceSources.ts +6 -25
- package/src/narrative/internal/utilities/createUnitFiles.ts +5 -7
- package/src/narrative/internal/utilities/index.ts +1 -1
- package/src/narrative/internal/utilities/referenceLocation.ts +8 -18
- package/lib/narrative/AuthoredPass.d.ts +0 -16
- package/lib/narrative/AuthoredPass.js +0 -3
- package/lib/narrative/AuthoredPass.js.map +0 -1
- package/lib/narrative/IProductionLayerStages.d.ts +0 -15
- package/lib/narrative/IProductionLayerStages.js.map +0 -1
- package/lib/narrative/internal/hasNaturalness.d.ts +0 -14
- package/lib/narrative/internal/hasNaturalness.js +0 -19
- package/lib/narrative/internal/hasNaturalness.js.map +0 -1
- package/lib/narrative/internal/utilities/passRoot.d.ts +0 -16
- package/lib/narrative/internal/utilities/passRoot.js +0 -22
- package/lib/narrative/internal/utilities/passRoot.js.map +0 -1
- package/lib/narrative/stripNaturalnessComments.d.ts +0 -12
- package/lib/narrative/stripNaturalnessComments.js +0 -34
- package/lib/narrative/stripNaturalnessComments.js.map +0 -1
- package/src/narrative/AuthoredPass.ts +0 -16
- package/src/narrative/IProductionLayerStages.ts +0 -16
- package/src/narrative/internal/hasNaturalness.ts +0 -17
- package/src/narrative/internal/utilities/passRoot.ts +0 -20
- package/src/narrative/stripNaturalnessComments.ts +0 -31
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stripNaturalnessComments = stripNaturalnessComments;
|
|
4
|
-
const node_util_1 = require("node:util");
|
|
5
|
-
/**
|
|
6
|
-
* Removes complete HTML comments without changing any surrounding UTF-8 bytes.
|
|
7
|
-
*
|
|
8
|
-
* @evidence contracts/development/implementation.md#principled-implementation Fatal UTF-8 decoding validates bytes before delimiter-based removal of every complete HTML comment; retained subarrays are concatenated without decoding/re-encoding them, preserving exact surrounding bytes.
|
|
9
|
-
* @evidence contracts/development/implementation.md#clear-and-simple-structure The helper owns only byte-preserving comment removal; topology and evidence metadata policy remain with their callers.
|
|
10
|
-
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Unclosed comments and invalid UTF-8 throw rather than being silently repaired; all HTML comments are removed regardless of evidence content.
|
|
11
|
-
* @evidence contracts/development/common.md#meaningful-documentation The comment promises complete-comment removal and exact surrounding UTF-8 preservation; the thrown error names an unterminated working comment.
|
|
12
|
-
* @evidence contracts/development/implementation.md#efficient-algorithms Decoding, forward delimiter searches and final concatenation take linear work in byte count; temporary decoded text, slice descriptors and returned bytes require linear memory.
|
|
13
|
-
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each buffer is processed independently because its bytes are the complete input and callers may mutate buffers; there is no coordinated request cache.
|
|
14
|
-
* @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources Subarray views retain input storage only until concatenation and return; the result owns its output bytes, and the function opens no handle or task.
|
|
15
|
-
*/
|
|
16
|
-
function stripNaturalnessComments(bytes) {
|
|
17
|
-
new node_util_1.TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
18
|
-
const chunks = [];
|
|
19
|
-
let offset = 0;
|
|
20
|
-
while (true) {
|
|
21
|
-
const opening = bytes.indexOf("<!--", offset);
|
|
22
|
-
if (opening === -1) {
|
|
23
|
-
chunks.push(bytes.subarray(offset));
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
const closing = bytes.indexOf("-->", opening + 4);
|
|
27
|
-
if (closing === -1)
|
|
28
|
-
throw new Error("Naturalness working file has an unclosed HTML comment.");
|
|
29
|
-
chunks.push(bytes.subarray(offset, opening));
|
|
30
|
-
offset = closing + 3;
|
|
31
|
-
}
|
|
32
|
-
return Buffer.concat(chunks);
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=stripNaturalnessComments.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripNaturalnessComments.js","sourceRoot":"","sources":["../../src/narrative/stripNaturalnessComments.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AAExC;;;;;;;;;;GAUG;AACH,kCAAyC,KAAa;IACpD,IAAI,uBAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,MAAM,GAAW,CAAC,CAAC;IACvB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,OAAO,GAAW,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,IAAI,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC;YACnB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YACpC,MAAM;QACR,CAAC;QACD,MAAM,OAAO,GAAW,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;QAC1D,IAAI,OAAO,KAAK,CAAC,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC5E,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAC7C,MAAM,GAAG,OAAO,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Names the two logical authored passes of one shared manuscript.
|
|
3
|
-
*
|
|
4
|
-
* `draft` means construction. `final` means screenplay naturalness. They select
|
|
5
|
-
* `docs/body` and `docs/naturalness` respectively; construction evidence is detached,
|
|
6
|
-
* while naturalness evidence stays inline in the working text.
|
|
7
|
-
*
|
|
8
|
-
* Naturalness compares its working text with the frozen construction snapshot
|
|
9
|
-
* in `docs/revision`. The source flag chooses upstream approval dependencies.
|
|
10
|
-
*
|
|
11
|
-
* @evidence contracts/development/design.md#principled-representation The closed draft/final spelling maps authoring selections to body versus naturalness trees; final is the expression revision, not a creative approval.
|
|
12
|
-
* @evidence contracts/development/design.md#minimal-and-owned-surface Two legacy selector spellings keep root selection separate from the construction/naturalness gate vocabulary.
|
|
13
|
-
* @evidence contracts/development/design.md#prohibited-design-shortcuts The alias does not certify creative completion; its final spelling is explicitly expression revision.
|
|
14
|
-
* @evidence contracts/development/common.md#meaningful-documentation The prose defines draft/final roots, detached versus inline evidence and frozen comparison dependencies.
|
|
15
|
-
*/
|
|
16
|
-
export type AuthoredPass = "draft" | "final";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ProductionStage } from "./ProductionStage";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The independent naturalness stage of final screenplay.
|
|
5
|
-
* Settings, treatments and scripts finish within construction; scripts
|
|
6
|
-
* construction also answers its expression questions.
|
|
7
|
-
*
|
|
8
|
-
* @evidence contracts/development/design.md#principled-representation Only screenplay has a separate expression stage; scripts construction owns its expression questions, and documentary layers finish within construction.
|
|
9
|
-
* @evidence contracts/development/design.md#minimal-and-owned-surface One field represents the actual revision pass without a frozen script-content cycle.
|
|
10
|
-
* @evidence contracts/development/design.md#prohibited-design-shortcuts The factory checks stage values; the type supplies no disabled-check compensation or special consumer path.
|
|
11
|
-
* @evidence contracts/development/common.md#meaningful-documentation The prose identifies construction-only layers and the screenplay naturalness stage.
|
|
12
|
-
*/
|
|
13
|
-
export interface IProductionLayerStages {
|
|
14
|
-
/** The stage of `screenplay` in this pass. */
|
|
15
|
-
screenplay: ProductionStage;
|
|
16
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { AuthoredLayer } from "../AuthoredLayer";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Only final screenplay has an independent expression pass. Scripts construction
|
|
5
|
-
* also answers expression questions so content-shaped defects remain repairable.
|
|
6
|
-
*
|
|
7
|
-
* @evidence contracts/development/implementation.md#principled-implementation Literal membership limits separate expression revision to screenplay; scripts expression remains in construction.
|
|
8
|
-
* @evidence contracts/development/implementation.md#clear-and-simple-structure The shared type guard keeps the same eligibility rule in claim factories and dependency validation.
|
|
9
|
-
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The admitted layer is the actual separate expression pass, not a consumer-specific exception.
|
|
10
|
-
* @evidence contracts/development/common.md#meaningful-documentation The comment identifies the separate expression layer and scripts construction responsibility; the return type narrows callers to the naturalness stage key.
|
|
11
|
-
* @evidence contracts/development/implementation.md#efficient-algorithms One literal comparison takes constant time and no collection allocation.
|
|
12
|
-
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work This pure membership predicate coordinates no reusable requests or effectful work.
|
|
13
|
-
* @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources The function owns no retained state, descriptor or task.
|
|
14
|
-
*/
|
|
15
|
-
export function hasNaturalness(layer: AuthoredLayer): layer is "screenplay" {
|
|
16
|
-
return layer === "screenplay";
|
|
17
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AuthoredPass } from "../../AuthoredPass";
|
|
2
|
-
import { PACKAGE_DOCS_ROOT } from "./PACKAGE_DOCS_ROOT";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Names the docs subtree one pass writes into.
|
|
6
|
-
*
|
|
7
|
-
* Construction reads the current manuscript. Naturalness is written, evidenced,
|
|
8
|
-
* and reviewed in its working tree before comment-free promotion to body.
|
|
9
|
-
*
|
|
10
|
-
* @evidence contracts/development/implementation.md#principled-implementation The draft edition addresses the current body tree and the final edition addresses the naturalness working tree; frozen revision references are deliberately handled by referenceLocation instead.
|
|
11
|
-
* @evidence contracts/development/implementation.md#clear-and-simple-structure One two-way pass-root rule is shared by authored claim factories, while upstream/frozen reference addressing stays with the relation owner.
|
|
12
|
-
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The final-to-naturalness mapping is the declared review-before-promotion lifecycle and does not redirect a consumer to fabricated final output.
|
|
13
|
-
* @evidence contracts/development/common.md#meaningful-documentation The prose explains current manuscript ownership and that naturalness is authored, evidenced and reviewed before comment-free promotion.
|
|
14
|
-
* @evidence contracts/development/implementation.md#efficient-algorithms One branch and string interpolation allocate a fixed-size relative path, independent of file population or document size.
|
|
15
|
-
* @evidence contracts/development/implementation.md#reuse-equivalent-work PACKAGE_DOCS_ROOT shares the directory spelling across callers; this pure fixed mapping has no effectful work or cross-request result cache.
|
|
16
|
-
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned path is caller-owned and constant-sized; there are no open handles, retained tasks or growing module collections.
|
|
17
|
-
*/
|
|
18
|
-
export function passRoot(pass: AuthoredPass): string {
|
|
19
|
-
return `${PACKAGE_DOCS_ROOT}/${pass === "final" ? "naturalness" : "body"}`;
|
|
20
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { TextDecoder } from "node:util";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Removes complete HTML comments without changing any surrounding UTF-8 bytes.
|
|
5
|
-
*
|
|
6
|
-
* @evidence contracts/development/implementation.md#principled-implementation Fatal UTF-8 decoding validates bytes before delimiter-based removal of every complete HTML comment; retained subarrays are concatenated without decoding/re-encoding them, preserving exact surrounding bytes.
|
|
7
|
-
* @evidence contracts/development/implementation.md#clear-and-simple-structure The helper owns only byte-preserving comment removal; topology and evidence metadata policy remain with their callers.
|
|
8
|
-
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Unclosed comments and invalid UTF-8 throw rather than being silently repaired; all HTML comments are removed regardless of evidence content.
|
|
9
|
-
* @evidence contracts/development/common.md#meaningful-documentation The comment promises complete-comment removal and exact surrounding UTF-8 preservation; the thrown error names an unterminated working comment.
|
|
10
|
-
* @evidence contracts/development/implementation.md#efficient-algorithms Decoding, forward delimiter searches and final concatenation take linear work in byte count; temporary decoded text, slice descriptors and returned bytes require linear memory.
|
|
11
|
-
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each buffer is processed independently because its bytes are the complete input and callers may mutate buffers; there is no coordinated request cache.
|
|
12
|
-
* @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources Subarray views retain input storage only until concatenation and return; the result owns its output bytes, and the function opens no handle or task.
|
|
13
|
-
*/
|
|
14
|
-
export function stripNaturalnessComments(bytes: Buffer): Buffer {
|
|
15
|
-
new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
16
|
-
const chunks: Buffer[] = [];
|
|
17
|
-
let offset: number = 0;
|
|
18
|
-
while (true) {
|
|
19
|
-
const opening: number = bytes.indexOf("<!--", offset);
|
|
20
|
-
if (opening === -1) {
|
|
21
|
-
chunks.push(bytes.subarray(offset));
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
const closing: number = bytes.indexOf("-->", opening + 4);
|
|
25
|
-
if (closing === -1)
|
|
26
|
-
throw new Error("Naturalness working file has an unclosed HTML comment.");
|
|
27
|
-
chunks.push(bytes.subarray(offset, opening));
|
|
28
|
-
offset = closing + 3;
|
|
29
|
-
}
|
|
30
|
-
return Buffer.concat(chunks);
|
|
31
|
-
}
|