@effected/templates 0.13.0 → 0.14.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/CommentStyle.js +1 -2
- package/ManagedSection.js +17 -15
- package/Section.js +1 -2
- package/SectionDialect.js +1 -2
- package/SectionDocument.js +1 -2
- package/SectionOutcome.js +1 -2
- package/index.d.ts +3 -14
- package/internal/attributes.js +1 -2
- package/internal/reconcile.js +1 -2
- package/internal/scan.js +1 -2
- package/package.json +1 -1
package/CommentStyle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/CommentStyle.ts
|
|
4
4
|
/**
|
|
5
5
|
* A comment delimiter: non-empty, and free of control characters.
|
|
6
6
|
*
|
|
@@ -99,5 +99,4 @@ var CommentStyle = class CommentStyle extends Schema.Class("CommentStyle")({
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
//#endregion
|
|
103
102
|
export { CommentStyle };
|
package/ManagedSection.js
CHANGED
|
@@ -2,7 +2,7 @@ import { SectionDialect } from "./SectionDialect.js";
|
|
|
2
2
|
import { SectionDocument, SectionParseError } from "./SectionDocument.js";
|
|
3
3
|
import { Context, Effect, FileSystem, Layer, Schema } from "effect";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/ManagedSection.ts
|
|
6
6
|
/**
|
|
7
7
|
* Raised when the file behind a managed-section operation could not be read or
|
|
8
8
|
* written.
|
|
@@ -126,9 +126,11 @@ const make = (options = {}) => Effect.gen(function* () {
|
|
|
126
126
|
})
|
|
127
127
|
};
|
|
128
128
|
});
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
/**
|
|
130
|
+
* An unstubbed `makeTest` member: dies when its effect runs, never when it is
|
|
131
|
+
* called, so building the effect outside a generator cannot throw.
|
|
132
|
+
*/
|
|
133
|
+
const unstubbed = (member) => () => Effect.die(/* @__PURE__ */ new Error(`ManagedSection.makeTest: ${member}() was called but not stubbed — pass a \`${member}\` override.`));
|
|
132
134
|
/**
|
|
133
135
|
* Managed sections in files: read, compare, sync and remove delimited blocks
|
|
134
136
|
* whose surrounding content belongs to the user.
|
|
@@ -181,18 +183,19 @@ var ManagedSection = class ManagedSection extends Context.Service()("@effected/t
|
|
|
181
183
|
*/
|
|
182
184
|
static layerWith = (options) => Layer.effect(ManagedSection, make(options));
|
|
183
185
|
/**
|
|
184
|
-
* A test double. Members a suite does not stub **die when
|
|
185
|
-
* than returning a plausible-looking
|
|
186
|
+
* A test double. Members a suite does not stub **die when run** (calling
|
|
187
|
+
* one only builds the effect), rather than returning a plausible-looking
|
|
188
|
+
* answer that makes a wrong test pass.
|
|
186
189
|
*/
|
|
187
190
|
static makeTest = (overrides = {}) => ({
|
|
188
|
-
read: (
|
|
189
|
-
readAll: (
|
|
190
|
-
isManaged: (
|
|
191
|
-
sync: (
|
|
192
|
-
syncAll: (
|
|
193
|
-
check: (
|
|
194
|
-
checkAll: (
|
|
195
|
-
remove: (
|
|
191
|
+
read: unstubbed("read"),
|
|
192
|
+
readAll: unstubbed("readAll"),
|
|
193
|
+
isManaged: unstubbed("isManaged"),
|
|
194
|
+
sync: unstubbed("sync"),
|
|
195
|
+
syncAll: unstubbed("syncAll"),
|
|
196
|
+
check: unstubbed("check"),
|
|
197
|
+
checkAll: unstubbed("checkAll"),
|
|
198
|
+
remove: unstubbed("remove"),
|
|
196
199
|
...overrides
|
|
197
200
|
});
|
|
198
201
|
/**
|
|
@@ -206,5 +209,4 @@ var ManagedSection = class ManagedSection extends Context.Service()("@effected/t
|
|
|
206
209
|
static layerTest = (overrides = {}) => Layer.succeed(ManagedSection, ManagedSection.makeTest(overrides));
|
|
207
210
|
};
|
|
208
211
|
|
|
209
|
-
//#endregion
|
|
210
212
|
export { ManagedSection, SectionFileError };
|
package/Section.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommentStyle } from "./CommentStyle.js";
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/Section.ts
|
|
5
5
|
/**
|
|
6
6
|
* The name identifying a managed section, as it literally appears in the
|
|
7
7
|
* file's markers.
|
|
@@ -146,5 +146,4 @@ var PlacedSection = class extends Schema.Class("PlacedSection")({
|
|
|
146
146
|
line: Schema.Number
|
|
147
147
|
}) {};
|
|
148
148
|
|
|
149
|
-
//#endregion
|
|
150
149
|
export { PlacedSection, Section, SectionId, SectionKey };
|
package/SectionDialect.js
CHANGED
|
@@ -2,7 +2,7 @@ import { CommentStyle } from "./CommentStyle.js";
|
|
|
2
2
|
import { ATTRIBUTE_NAME_PATTERN, isValidAttributeValue, parseAttributeRun } from "./internal/attributes.js";
|
|
3
3
|
import { Equal, Result, Schema } from "effect";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/SectionDialect.ts
|
|
6
6
|
/**
|
|
7
7
|
* Raised when a section cannot be turned into marker-delimited text.
|
|
8
8
|
*
|
|
@@ -179,5 +179,4 @@ var SectionDialect = class SectionDialect extends Schema.Class("SectionDialect")
|
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
-
//#endregion
|
|
183
182
|
export { SectionDialect, SectionRenderError };
|
package/SectionDocument.js
CHANGED
|
@@ -5,7 +5,7 @@ import { SCAN_FAILURE_REASONS, detectEol, identityOf, normalizeEol, scan } from
|
|
|
5
5
|
import { reconcile } from "./internal/reconcile.js";
|
|
6
6
|
import { Effect, Equal, Option, Result, Schema } from "effect";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/SectionDocument.ts
|
|
9
9
|
/**
|
|
10
10
|
* Raised when a document's managed-section structure cannot be read without
|
|
11
11
|
* guessing.
|
|
@@ -193,5 +193,4 @@ var SectionDocument = class SectionDocument extends Schema.Class("SectionDocumen
|
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
//#endregion
|
|
197
196
|
export { SectionDocument, SectionParseError };
|
package/SectionOutcome.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Data } from "effect";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/SectionOutcome.ts
|
|
4
4
|
/**
|
|
5
5
|
* Constructors and matchers for `SyncOutcome` — e.g.
|
|
6
6
|
* `SyncOutcome.Created({ section })`, `SyncOutcome.$is("Updated")`.
|
|
@@ -16,5 +16,4 @@ const SyncOutcome = Data.taggedEnum();
|
|
|
16
16
|
*/
|
|
17
17
|
const CheckOutcome = Data.taggedEnum();
|
|
18
18
|
|
|
19
|
-
//#endregion
|
|
20
19
|
export { CheckOutcome, SyncOutcome };
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Context, Data, Effect, FileSystem, Layer, Option, Result, Schema } from "effect";
|
|
2
|
-
//#region src/CommentStyle.d.ts
|
|
3
2
|
declare const CommentStyle_base: Schema.Class<CommentStyle, Schema.Struct<{
|
|
4
3
|
/** Opens the comment. Non-empty, single-line. */
|
|
5
4
|
readonly prefix: Schema.String;
|
|
@@ -65,8 +64,6 @@ export declare class CommentStyle extends CommentStyle_base {
|
|
|
65
64
|
/** True when the style wraps its content, i.e. it carries a suffix. */
|
|
66
65
|
get isWrapped(): boolean;
|
|
67
66
|
}
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/Section.d.ts
|
|
70
67
|
/**
|
|
71
68
|
* The name identifying a managed section, as it literally appears in the
|
|
72
69
|
* file's markers.
|
|
@@ -194,8 +191,6 @@ declare const PlacedSection_base: Schema.Class<PlacedSection, Schema.Struct<{
|
|
|
194
191
|
* @public
|
|
195
192
|
*/
|
|
196
193
|
export declare class PlacedSection extends PlacedSection_base {}
|
|
197
|
-
//#endregion
|
|
198
|
-
//#region src/SectionDialect.d.ts
|
|
199
194
|
/**
|
|
200
195
|
* The line ending a document uses.
|
|
201
196
|
*
|
|
@@ -310,8 +305,6 @@ export declare class SectionDialect extends SectionDialect_base {
|
|
|
310
305
|
}>;
|
|
311
306
|
private marker;
|
|
312
307
|
}
|
|
313
|
-
//#endregion
|
|
314
|
-
//#region src/SectionOutcome.d.ts
|
|
315
308
|
/**
|
|
316
309
|
* What a sync did to one declared section.
|
|
317
310
|
*
|
|
@@ -542,8 +535,6 @@ export declare const CheckOutcome: {
|
|
|
542
535
|
readonly section: Section;
|
|
543
536
|
}, "_tag">;
|
|
544
537
|
};
|
|
545
|
-
//#endregion
|
|
546
|
-
//#region src/SectionDocument.d.ts
|
|
547
538
|
declare const SectionParseError_base: Schema.Class<SectionParseError, Schema.TaggedStruct<"SectionParseError", {
|
|
548
539
|
/** Which ambiguity was found. */
|
|
549
540
|
readonly reason: Schema.Literals<readonly ["unterminatedSection", "orphanedEnd", "overlappingSections", "duplicateSection"]>;
|
|
@@ -685,8 +676,6 @@ export declare class SectionDocument extends SectionDocument_base {
|
|
|
685
676
|
*/
|
|
686
677
|
remove(id: SectionId): Option.Option<string>;
|
|
687
678
|
}
|
|
688
|
-
//#endregion
|
|
689
|
-
//#region src/ManagedSection.d.ts
|
|
690
679
|
declare const SectionFileError_base: Schema.Class<SectionFileError, Schema.TaggedStruct<"SectionFileError", {
|
|
691
680
|
/** The file the operation was against. */
|
|
692
681
|
readonly path: Schema.String;
|
|
@@ -813,8 +802,9 @@ export declare class ManagedSection extends ManagedSection_base {
|
|
|
813
802
|
*/
|
|
814
803
|
static readonly layerWith: (options: ManagedSectionOptions) => Layer.Layer<ManagedSection, never, FileSystem.FileSystem>;
|
|
815
804
|
/**
|
|
816
|
-
* A test double. Members a suite does not stub **die when
|
|
817
|
-
* than returning a plausible-looking
|
|
805
|
+
* A test double. Members a suite does not stub **die when run** (calling
|
|
806
|
+
* one only builds the effect), rather than returning a plausible-looking
|
|
807
|
+
* answer that makes a wrong test pass.
|
|
818
808
|
*/
|
|
819
809
|
static readonly makeTest: (overrides?: Partial<ManagedSectionShape>) => ManagedSectionShape;
|
|
820
810
|
/**
|
|
@@ -827,6 +817,5 @@ export declare class ManagedSection extends ManagedSection_base {
|
|
|
827
817
|
*/
|
|
828
818
|
static readonly layerTest: (overrides?: Partial<ManagedSectionShape>) => Layer.Layer<ManagedSection>;
|
|
829
819
|
}
|
|
830
|
-
//#endregion
|
|
831
820
|
export type { Eol, ManagedSectionOptions, ManagedSectionShape, SectionReconciliation };
|
|
832
821
|
//# sourceMappingURL=index.d.ts.map
|
package/internal/attributes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/attributes.ts
|
|
2
2
|
/** The attribute name grammar. No leading digit, underscore or dash. */
|
|
3
3
|
const ATTRIBUTE_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
4
4
|
/** True when a value can appear inside an attribute's double quotes verbatim. */
|
|
@@ -59,5 +59,4 @@ const parseAttributeRun = (run) => {
|
|
|
59
59
|
return first ? void 0 : attributes;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
//#endregion
|
|
63
62
|
export { ATTRIBUTE_NAME_PATTERN, isValidAttributeValue, parseAttributeRun };
|
package/internal/reconcile.js
CHANGED
|
@@ -3,7 +3,7 @@ import { SyncOutcome } from "../SectionOutcome.js";
|
|
|
3
3
|
import { identityOf } from "./scan.js";
|
|
4
4
|
import { Equal, Result } from "effect";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/internal/reconcile.ts
|
|
7
7
|
const reconcile = (input) => {
|
|
8
8
|
const { text, placed, declared, dialect, eol } = input;
|
|
9
9
|
const rendered = /* @__PURE__ */ new Map();
|
|
@@ -109,5 +109,4 @@ const reconcile = (input) => {
|
|
|
109
109
|
});
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
//#endregion
|
|
113
112
|
export { reconcile };
|
package/internal/scan.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseAttributeRun } from "./attributes.js";
|
|
2
2
|
import { PlacedSection, Section } from "../Section.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/internal/scan.ts
|
|
5
5
|
/** The ways a document can be structurally unreadable. */
|
|
6
6
|
const SCAN_FAILURE_REASONS = [
|
|
7
7
|
"unterminatedSection",
|
|
@@ -141,5 +141,4 @@ const scan = (text, dialect) => {
|
|
|
141
141
|
};
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
//#endregion
|
|
145
144
|
export { SCAN_FAILURE_REASONS, detectEol, identityOf, normalizeEol, scan };
|