@patterkit/ops 0.7.6 → 0.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/index.d.ts +185 -17
- package/dist/index.js +431 -123
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,153 @@
|
|
|
1
|
-
import { ProjectFile, Scene, LocaleFile, AuthoringFile,
|
|
1
|
+
import { ProjectFile, Bundle, HostScopeRegistry, Scene, LocaleFile, AuthoringFile, GameData, CoverageDriver, GrammaticalGender, DocumentationClass, DocLine } from '@patterkit/model';
|
|
2
|
+
import { NamedScopesFile, MergedScopes, ScopesIssue, ScopesCatalogueEntry, ScopesFile } from '@wildwinter/scoperegistry/scopes';
|
|
3
|
+
export { GAME_SCOPES_DIR, GAME_SCOPES_FILE, serialiseScopesFile } from '@wildwinter/scoperegistry/scopes';
|
|
4
|
+
import { ScopeDeclaration, ScopeRegistry } from '@wildwinter/scoperegistry';
|
|
2
5
|
import { ValidationIssue } from '@patterkit/core';
|
|
3
6
|
import { ConditionIssue } from '@patterkit/compiler';
|
|
4
7
|
import { ChoiceOption } from '@patterkit/runtime';
|
|
5
8
|
export { isUnsafeEntry } from '@wildwinter/toolkit/archive';
|
|
6
9
|
|
|
10
|
+
/** One file write an op wants performed. `content` is full canonical file text. */
|
|
11
|
+
interface PlannedWrite {
|
|
12
|
+
path: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Commit planned writes to disk (UTF-8), creating parent directories. The PLAIN
|
|
17
|
+
* filesystem applier - for tests and no-VCS embedders only; product code (the
|
|
18
|
+
* CLI, Patterpad) routes through @patterkit/vcs so writes land correctly in a
|
|
19
|
+
* Perforce / locked workspace (spec §12).
|
|
20
|
+
*/
|
|
21
|
+
declare function applyWrites(writes: PlannedWrite[]): void;
|
|
22
|
+
|
|
23
|
+
/** Patter's own file in the folder. */
|
|
24
|
+
declare const PATTER_SCOPES_FILE = "patter.scopes.json";
|
|
25
|
+
/** Who Patter's file says wrote it. */
|
|
26
|
+
declare const PATTER_SCOPES_OWNER = "Patter";
|
|
27
|
+
/** Who the game's own file says wrote it, when Patter is the first to create it. */
|
|
28
|
+
declare const GAME_SCOPES_OWNER = "Game";
|
|
29
|
+
/** A project's game scopes folder, read and merged. */
|
|
30
|
+
interface GameScopes {
|
|
31
|
+
/** The folder, absolute. */
|
|
32
|
+
dir: string;
|
|
33
|
+
/** Every scopes file in it that parsed, by name. */
|
|
34
|
+
files: NamedScopesFile[];
|
|
35
|
+
/** The whole folder as one spec, with who declares each token. */
|
|
36
|
+
merged: MergedScopes;
|
|
37
|
+
/** Files that would not parse and tokens two files claim, each naming its file (absolute). */
|
|
38
|
+
issues: ScopesIssue[];
|
|
39
|
+
/** The text of `patter.scopes.json` as it was read, or undefined when there is none yet. */
|
|
40
|
+
patterText?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Read and merge every `*.scopes.json` in a game scopes folder. */
|
|
43
|
+
declare function readGameScopes(dir: string): GameScopes;
|
|
44
|
+
/**
|
|
45
|
+
* Find and read a project's game scopes: the project's `gameScopes` override (relative to the project
|
|
46
|
+
* file's folder), else the walk-up from that folder. `missing` is the error for an override naming a
|
|
47
|
+
* folder that doesn't exist; no folder at all is not an error.
|
|
48
|
+
*/
|
|
49
|
+
declare function discoverGameScopes(root: string, project: ProjectFile): {
|
|
50
|
+
gameScopes?: GameScopes;
|
|
51
|
+
missing?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The game's scopes files as a pack carries them (patterkit/design/shared-scopes.md, "Packs"): every
|
|
55
|
+
* `*.scopes.json` in the folder the loader would find, by name, as its text on disk, sorted by name.
|
|
56
|
+
* Empty when there is no folder (or the project names one that isn't there), so a pack is as it was.
|
|
57
|
+
* A file that won't parse travels too: the snapshot is the folder as it is, not as Patter reads it.
|
|
58
|
+
*/
|
|
59
|
+
declare function gameScopesSnapshot(root: string, project: ProjectFile): Array<{
|
|
60
|
+
fileName: string;
|
|
61
|
+
text: string;
|
|
62
|
+
}>;
|
|
63
|
+
/** Patter's scopes file for a project: its shared `@patter` properties, in declaration order. */
|
|
64
|
+
declare function patterScopesFile(project: ProjectFile): ScopesFile;
|
|
65
|
+
/**
|
|
66
|
+
* The write that brings `patter.scopes.json` up to date, or undefined when there is no folder or the
|
|
67
|
+
* file already says exactly this. Never creates the folder: only a folder that was found gets a file.
|
|
68
|
+
*/
|
|
69
|
+
declare function patterScopesWrite(project: ProjectFile, gameScopes: GameScopes | undefined): PlannedWrite | undefined;
|
|
70
|
+
/** The warning `validate` gives when `patter.scopes.json` doesn't say what the project would write. */
|
|
71
|
+
declare function patterScopesStale(project: ProjectFile, gameScopes: GameScopes | undefined): {
|
|
72
|
+
file: string;
|
|
73
|
+
message: string;
|
|
74
|
+
} | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* The registry a PREVIEW builds its engine on, when the project has game scopes and the bundle names
|
|
77
|
+
* someone else's scope (`@story`, a game scope the project doesn't declare): every scope in the folder
|
|
78
|
+
* but Patter's, stood in from its declared defaults, plus the bundle's own host scopes, since an engine
|
|
79
|
+
* given a registry self-backs nothing. Undefined when a preview needs no stand-ins, so the engine makes
|
|
80
|
+
* its own registry exactly as before. Preview only: a game's registry holds the real engines.
|
|
81
|
+
*/
|
|
82
|
+
declare function previewRegistry(gameScopes: GameScopes | undefined, bundle: Bundle, into?: ScopeRegistry): ScopeRegistry | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* The scopes a coverage run can feed and must treat as the game's to write: the bundle's host scopes,
|
|
85
|
+
* and, where a preview stands other scopes in (`previewRegistry`), those too. Without a folder, just the
|
|
86
|
+
* bundle's host scopes, which are the project's own.
|
|
87
|
+
*/
|
|
88
|
+
declare function drivableScopes(loaded: {
|
|
89
|
+
gameScopes?: GameScopes;
|
|
90
|
+
}, bundle: Bundle): Array<{
|
|
91
|
+
token: string;
|
|
92
|
+
declarations?: ScopeDeclaration[];
|
|
93
|
+
}>;
|
|
94
|
+
/** The tokens of `drivableScopes`. */
|
|
95
|
+
declare const hostScopeTokens: (loaded: {
|
|
96
|
+
gameScopes?: GameScopes;
|
|
97
|
+
}, bundle: Bundle) => Set<string>;
|
|
98
|
+
/** The folder's properties for an expression editor's picker, every scope but Patter's own. */
|
|
99
|
+
declare const gameScopesCatalogue: (gameScopes: GameScopes | undefined) => ScopesCatalogueEntry[];
|
|
100
|
+
/** The folder's tokens, every one but Patter's own: an editor's parser must know them all. */
|
|
101
|
+
declare const gameScopeTokens: (gameScopes: GameScopes | undefined) => string[];
|
|
102
|
+
/**
|
|
103
|
+
* The host scopes World properties shows: the project's, with each one `game.scopes.json` declares
|
|
104
|
+
* taken from there (the shared file is the source; the project holds a synced copy), and the shared
|
|
105
|
+
* `@world` added when the project has none. Without a folder, the project's own.
|
|
106
|
+
*/
|
|
107
|
+
declare function worldSettingsScopes(project: ProjectFile, gameScopes: GameScopes | undefined): HostScopeRegistry | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Save World properties where the project has a game scopes folder: the game's own scopes go to
|
|
110
|
+
* `game.scopes.json` FIRST (re-read just now, so another tool's edit since is kept, and every scope this
|
|
111
|
+
* project doesn't show is left exactly as it was), then the project keeps the same scopes as its synced
|
|
112
|
+
* copy, so it still compiles packed or checked out alone. Another engine's scope stays in the project
|
|
113
|
+
* only. Returns the write for the shared file (none when its text wouldn't change), and the project's
|
|
114
|
+
* host scopes; or an error when the shared file is there but won't parse, rather than overwrite it.
|
|
115
|
+
*/
|
|
116
|
+
declare function planWorldSave(project: ProjectFile, gameScopes: GameScopes, next: HostScopeRegistry | undefined): {
|
|
117
|
+
write?: PlannedWrite;
|
|
118
|
+
scopeRegistry?: HostScopeRegistry;
|
|
119
|
+
error?: string;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Merging a returned pack (patterkit/design/shared-scopes.md, "Packs"): the recipient's World edit comes
|
|
123
|
+
* back in the project's synced copy of the game's scopes, and the sender's `game.scopes.json` must take
|
|
124
|
+
* it, or the next save would sync the copy from the shared file and silently drop it. The scopes the
|
|
125
|
+
* returned project file declares differently from the base pack's are the ones the recipient changed
|
|
126
|
+
* (added, edited, or deleted); each goes to `game.scopes.json` as the MERGED project has it, through the
|
|
127
|
+
* World settings' own save, and every other scope in the file stays exactly as it is now. Nothing (no
|
|
128
|
+
* write) when the recipient changed none of the game's scopes; an error when the file won't parse.
|
|
129
|
+
*/
|
|
130
|
+
declare function planReturnedWorld(ours: ProjectFile, base: ProjectFile, theirs: ProjectFile, merged: ProjectFile, gameScopes: GameScopes): {
|
|
131
|
+
write?: PlannedWrite;
|
|
132
|
+
error?: string;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Where "Share scopes with other tools" suggests creating the folder: at the version-control root above
|
|
136
|
+
* the project (the first folder holding `.git`), else beside the project folder.
|
|
137
|
+
*/
|
|
138
|
+
declare function defaultGameScopesDir(root: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Share a project's scopes with the game's other tools: create `game-scopes/` at `dir` with Patter's
|
|
141
|
+
* file and `game.scopes.json` holding the project's own game scopes (its host scopes, but not another
|
|
142
|
+
* engine's, which is that engine's to declare). The project keeps its copy. When the walk-up from the
|
|
143
|
+
* project would not find `dir`, the project names it (`gameScopes`), so it is found next time. Returns
|
|
144
|
+
* the writes (the folder comes with the first), and the project as it should now be saved.
|
|
145
|
+
*/
|
|
146
|
+
declare function planShareScopes(root: string, project: ProjectFile, dir: string): {
|
|
147
|
+
writes: PlannedWrite[];
|
|
148
|
+
project: ProjectFile;
|
|
149
|
+
};
|
|
150
|
+
|
|
7
151
|
interface LoadedProject {
|
|
8
152
|
root: string;
|
|
9
153
|
projectFile: string;
|
|
@@ -18,6 +162,11 @@ interface LoadedProject {
|
|
|
18
162
|
authoring: AuthoringFile[];
|
|
19
163
|
/** Source file of each entry in `authoring`, index-aligned. */
|
|
20
164
|
authoringFiles: string[];
|
|
165
|
+
/** The game's shared scopes folder, read and merged, when the project has one (discovered by walking
|
|
166
|
+
* up, or named by the project's `gameScopes`). Absent = the project works alone. */
|
|
167
|
+
gameScopes?: GameScopes;
|
|
168
|
+
/** The project names a game scopes folder (`gameScopes`) that doesn't exist: a project error. */
|
|
169
|
+
gameScopesMissing?: string;
|
|
21
170
|
}
|
|
22
171
|
/**
|
|
23
172
|
* Find the nearest `*.patterproj` at or above `startPath` - one readdir per
|
|
@@ -54,24 +203,20 @@ declare function loadProjectLanding(startPath: string, opts?: {
|
|
|
54
203
|
declare function applySceneOrder(scenes: Scene[], order: string[] | undefined): void;
|
|
55
204
|
declare function loadProject(startPath: string): LoadedProject;
|
|
56
205
|
|
|
57
|
-
/** One file write an op wants performed. `content` is full canonical file text. */
|
|
58
|
-
interface PlannedWrite {
|
|
59
|
-
path: string;
|
|
60
|
-
content: string;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Commit planned writes to disk (UTF-8), creating parent directories. The PLAIN
|
|
64
|
-
* filesystem applier - for tests and no-VCS embedders only; product code (the
|
|
65
|
-
* CLI, Patterpad) routes through @patterkit/vcs so writes land correctly in a
|
|
66
|
-
* Perforce / locked workspace (spec §12).
|
|
67
|
-
*/
|
|
68
|
-
declare function applyWrites(writes: PlannedWrite[]): void;
|
|
69
|
-
|
|
70
206
|
/** A raw-bytes hygiene problem in one source file (repairable by `format`). */
|
|
71
207
|
interface HygieneIssue {
|
|
72
208
|
file: string;
|
|
73
209
|
message: string;
|
|
74
210
|
}
|
|
211
|
+
/** A problem with the game's shared scopes folder, or between it and the project, anchored to a file. */
|
|
212
|
+
interface GameScopesIssue {
|
|
213
|
+
file: string;
|
|
214
|
+
message: string;
|
|
215
|
+
/** "error" (a scopes file that won't parse, a token two files claim, an override that names no folder)
|
|
216
|
+
* blocks a clean build; "warning" (Patter's file out of date, the project's copy of a game scope
|
|
217
|
+
* differing from the shared file) does not. */
|
|
218
|
+
severity: "error" | "warning";
|
|
219
|
+
}
|
|
75
220
|
interface ValidateResult {
|
|
76
221
|
structural: ValidationIssue[];
|
|
77
222
|
conditions: ConditionIssue[];
|
|
@@ -89,6 +234,10 @@ interface ValidateResult {
|
|
|
89
234
|
unresolvedMerges: HygieneIssue[];
|
|
90
235
|
/** Patter shards on disk that the project does NOT contain - see `orphanShards`. */
|
|
91
236
|
orphans: HygieneIssue[];
|
|
237
|
+
/** The game's shared scopes folder: its files, and how the project stands against them. Only the
|
|
238
|
+
* errors count against `ok`. Empty when the project has no folder. */
|
|
239
|
+
gameScopes: GameScopesIssue[];
|
|
240
|
+
/** Only ERRORS count: a warning (another tool's scope, say) never fails a build. */
|
|
92
241
|
ok: boolean;
|
|
93
242
|
}
|
|
94
243
|
/** Run structural + expression + interpolation + hygiene + bundle-staleness + merge validation. */
|
|
@@ -783,6 +932,9 @@ interface DocumentManifest {
|
|
|
783
932
|
};
|
|
784
933
|
/** Shard paths (relative, forward-slashed), sorted - the document's contents. */
|
|
785
934
|
files: string[];
|
|
935
|
+
/** The game scopes files the pack carries as `game-scopes/<name>` entries, by name, sorted. Absent
|
|
936
|
+
* when the project has no game scopes folder (or it holds none). */
|
|
937
|
+
gameScopes?: string[];
|
|
786
938
|
}
|
|
787
939
|
/** Pack a project's source shards into a `.patterpack` document (zip bytes). */
|
|
788
940
|
declare function runPack(startPath: string): Promise<Buffer>;
|
|
@@ -852,8 +1004,16 @@ declare const AUTHORING_HANDLED: Set<string>;
|
|
|
852
1004
|
/** A document entry whose path escapes the target dir (rejected). */
|
|
853
1005
|
declare class UnsafeEntryError extends Error {
|
|
854
1006
|
}
|
|
1007
|
+
/** What unpacking a document plans: its shards, and its game scopes snapshot (empty for a pack with none,
|
|
1008
|
+
* which is every pack from before packs carried one). */
|
|
1009
|
+
interface UnpackResult {
|
|
1010
|
+
/** The shards, under `targetDir`. */
|
|
1011
|
+
shards: PlannedWrite[];
|
|
1012
|
+
/** The game's scopes files, in `<targetDir>/game-scopes/`, where the new project finds them first. */
|
|
1013
|
+
scopes: PlannedWrite[];
|
|
1014
|
+
}
|
|
855
1015
|
/** Unpack a `.patterpack` document (zip bytes) into planned writes under `targetDir`. */
|
|
856
|
-
declare function runUnpack(bytes: Buffer | Uint8Array, targetDir: string): Promise<
|
|
1016
|
+
declare function runUnpack(bytes: Buffer | Uint8Array, targetDir: string): Promise<UnpackResult>;
|
|
857
1017
|
/** One shard's outcome in a merge-unpack. */
|
|
858
1018
|
interface MergedShard {
|
|
859
1019
|
/** Relative path within the project. */
|
|
@@ -890,7 +1050,8 @@ interface ProvenanceCheck {
|
|
|
890
1050
|
}
|
|
891
1051
|
interface UnpackMergeResult {
|
|
892
1052
|
shards: MergedShard[];
|
|
893
|
-
/** Merged (and added) shard contents to write into the project.
|
|
1053
|
+
/** Merged (and added) shard contents to write into the project, and `game.scopes.json` when the
|
|
1054
|
+
* recipient changed the game's scopes (`gameScopes`). */
|
|
894
1055
|
writes: PlannedWrite[];
|
|
895
1056
|
/** `.patterconflict` sidecars for shards with conflicts. */
|
|
896
1057
|
sidecars: PlannedWrite[];
|
|
@@ -898,6 +1059,13 @@ interface UnpackMergeResult {
|
|
|
898
1059
|
warnings: number;
|
|
899
1060
|
/** Do the returned document, the base document and the target project agree on their project id? */
|
|
900
1061
|
provenance: ProvenanceCheck;
|
|
1062
|
+
/** The recipient changed the game's scopes (World properties) and the project has a game scopes
|
|
1063
|
+
* folder: `path` is its `game.scopes.json`, which `writes` brings up to date, or, with `error`, the
|
|
1064
|
+
* file that won't parse and so was left alone. Absent otherwise. */
|
|
1065
|
+
gameScopes?: {
|
|
1066
|
+
path: string;
|
|
1067
|
+
error?: string;
|
|
1068
|
+
};
|
|
901
1069
|
}
|
|
902
1070
|
/**
|
|
903
1071
|
* Merge a RETURNED `.patterpack` document (`theirs`) back into the project at
|
|
@@ -919,4 +1087,4 @@ declare function classesForChannel(classes: DocumentationClass[], channel: strin
|
|
|
919
1087
|
*/
|
|
920
1088
|
declare function resolveDocumentation(loaded: LoadedProject, channel: string): Map<string, DocLine[]>;
|
|
921
1089
|
|
|
922
|
-
export { AUTHORING_HANDLED, type ApplyStats, type BundlePosture, CONFLICT_SIDECAR, type CharacterReport, type Conflict, type ConflictKind, type CoverageAsyncHooks, type CoverageBeat, type CoverageHooks, type CoverageOptions, type CoverageReport, type DocumentManifest, type FormatResult, type HygieneIssue, type InitOptions, type InitResult, type InitVcs, type LoadedProject, type LocCatalog, type LocEntry, type LocaleReport, type MergeFileType, type MergeResult, type MergedShard, type PlannedWrite, type PlayEvent, type PlayOptions, type PlayOutcome, type PlayResult, type ProvenanceCheck, type ReplaceHit, type ReplaceOptions, type ReplacePlan, type ReportData, type ReportTotals, type ResolveEntry, SHARD_EXTENSIONS, type SceneReport, type ScriptDoc, type ScriptElement, type SearchFocus, type UnpackMergeResult, UnsafeEntryError, UnsupportedMergeError, type ValidateResult, type VoiceLine, type VoiceScript, type VoicedCounts, type WebExport, type WrittenCounts, applyLoc, applySceneOrder, applyWrites, bundleOutputPath, catalogToJson, catalogToPo, catalogToXlsx, classesForChannel, detectMergeType, extractLoc, findProjectFile, jsonToCatalog, listProjectTags, loadProject, loadProjectLanding, poToCatalog, proposeCoverageDrivers, reachabilityIssues, renderCoverageText, renderPlay, renderReportText, resolveDocumentation, resolveStart, runCoverage, runCoverageAsync, runExport, runExportFull, runExportHtml, runExportWeb, runFormat, runInit, runMerge, runPack, runPlay, runPropertyUsage, runReplace, runReport, runReportXlsx, runResolve, runScriptDoc, runSearch, runStatusBrowse, runTagBrowse, runUnpack, runUnpackMerge, runValidate, runVoiceScript, scanAudioStatus, sceneIdForShard, scriptToDocx, scriptToPdf, sidecarIssues, vcsConfigWrites, voiceScriptToXlsx, xlsxToCatalog };
|
|
1090
|
+
export { AUTHORING_HANDLED, type ApplyStats, type BundlePosture, CONFLICT_SIDECAR, type CharacterReport, type Conflict, type ConflictKind, type CoverageAsyncHooks, type CoverageBeat, type CoverageHooks, type CoverageOptions, type CoverageReport, type DocumentManifest, type FormatResult, GAME_SCOPES_OWNER, type GameScopes, type GameScopesIssue, type HygieneIssue, type InitOptions, type InitResult, type InitVcs, type LoadedProject, type LocCatalog, type LocEntry, type LocaleReport, type MergeFileType, type MergeResult, type MergedShard, PATTER_SCOPES_FILE, PATTER_SCOPES_OWNER, type PlannedWrite, type PlayEvent, type PlayOptions, type PlayOutcome, type PlayResult, type ProvenanceCheck, type ReplaceHit, type ReplaceOptions, type ReplacePlan, type ReportData, type ReportTotals, type ResolveEntry, SHARD_EXTENSIONS, type SceneReport, type ScriptDoc, type ScriptElement, type SearchFocus, type UnpackMergeResult, type UnpackResult, UnsafeEntryError, UnsupportedMergeError, type ValidateResult, type VoiceLine, type VoiceScript, type VoicedCounts, type WebExport, type WrittenCounts, applyLoc, applySceneOrder, applyWrites, bundleOutputPath, catalogToJson, catalogToPo, catalogToXlsx, classesForChannel, defaultGameScopesDir, detectMergeType, discoverGameScopes, drivableScopes, extractLoc, findProjectFile, gameScopeTokens, gameScopesCatalogue, gameScopesSnapshot, hostScopeTokens, jsonToCatalog, listProjectTags, loadProject, loadProjectLanding, patterScopesFile, patterScopesStale, patterScopesWrite, planReturnedWorld, planShareScopes, planWorldSave, poToCatalog, previewRegistry, proposeCoverageDrivers, reachabilityIssues, readGameScopes, renderCoverageText, renderPlay, renderReportText, resolveDocumentation, resolveStart, runCoverage, runCoverageAsync, runExport, runExportFull, runExportHtml, runExportWeb, runFormat, runInit, runMerge, runPack, runPlay, runPropertyUsage, runReplace, runReport, runReportXlsx, runResolve, runScriptDoc, runSearch, runStatusBrowse, runTagBrowse, runUnpack, runUnpackMerge, runValidate, runVoiceScript, scanAudioStatus, sceneIdForShard, scriptToDocx, scriptToPdf, sidecarIssues, vcsConfigWrites, voiceScriptToXlsx, worldSettingsScopes, xlsxToCatalog };
|