@patterkit/model 0.21.0 → 0.22.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.cjs +16 -0
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +12 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,9 @@ __export(index_exports, {
|
|
|
36
36
|
EXTENSION_SHARD: () => EXTENSION_SHARD,
|
|
37
37
|
FLOW_SCHEMA: () => FLOW_SCHEMA,
|
|
38
38
|
HANDOFF_SCHEMA: () => HANDOFF_SCHEMA,
|
|
39
|
+
LINE_CHARS_PER_SECOND: () => LINE_CHARS_PER_SECOND,
|
|
40
|
+
LINE_DURATION_MAX: () => LINE_DURATION_MAX,
|
|
41
|
+
LINE_DURATION_MIN: () => LINE_DURATION_MIN,
|
|
39
42
|
MANIFEST_EXTENSION: () => MANIFEST_EXTENSION,
|
|
40
43
|
PAD_AFTER_MAX: () => PAD_AFTER_MAX,
|
|
41
44
|
PAD_AFTER_MIN: () => PAD_AFTER_MIN,
|
|
@@ -53,6 +56,7 @@ __export(index_exports, {
|
|
|
53
56
|
castStringKey: () => castStringKey,
|
|
54
57
|
deriveRecordingFolders: () => deriveRecordingFolders,
|
|
55
58
|
effectiveGameId: () => effectiveGameId,
|
|
59
|
+
estimateLineDuration: () => estimateLineDuration,
|
|
56
60
|
formatSpeakerLabel: () => formatSpeakerLabel,
|
|
57
61
|
gameIdify: () => import_toolkit.gameIdify,
|
|
58
62
|
isCaseOnlyPropertyName: () => import_expr.isCaseOnlyPropertyName,
|
|
@@ -172,6 +176,14 @@ function textIsAction(project, scene) {
|
|
|
172
176
|
var DEFAULT_PAD_AFTER = 0.6;
|
|
173
177
|
var PAD_AFTER_MIN = -10;
|
|
174
178
|
var PAD_AFTER_MAX = 60;
|
|
179
|
+
var LINE_CHARS_PER_SECOND = 14;
|
|
180
|
+
var LINE_DURATION_MIN = 1.5;
|
|
181
|
+
var LINE_DURATION_MAX = 18;
|
|
182
|
+
function estimateLineDuration(text, _locale) {
|
|
183
|
+
let count = 0;
|
|
184
|
+
for (const ch of text ?? "") if (ch !== "\xAD") count++;
|
|
185
|
+
return Math.min(Math.max(count / LINE_CHARS_PER_SECOND, LINE_DURATION_MIN), LINE_DURATION_MAX);
|
|
186
|
+
}
|
|
175
187
|
var DEFAULT_WRITING_STATUSES = [
|
|
176
188
|
{ name: "stub", colour: 0 },
|
|
177
189
|
// red
|
|
@@ -265,6 +277,9 @@ var UNRESOLVED_KEY = "unresolved";
|
|
|
265
277
|
EXTENSION_SHARD,
|
|
266
278
|
FLOW_SCHEMA,
|
|
267
279
|
HANDOFF_SCHEMA,
|
|
280
|
+
LINE_CHARS_PER_SECOND,
|
|
281
|
+
LINE_DURATION_MAX,
|
|
282
|
+
LINE_DURATION_MIN,
|
|
268
283
|
MANIFEST_EXTENSION,
|
|
269
284
|
PAD_AFTER_MAX,
|
|
270
285
|
PAD_AFTER_MIN,
|
|
@@ -282,6 +297,7 @@ var UNRESOLVED_KEY = "unresolved";
|
|
|
282
297
|
castStringKey,
|
|
283
298
|
deriveRecordingFolders,
|
|
284
299
|
effectiveGameId,
|
|
300
|
+
estimateLineDuration,
|
|
285
301
|
formatSpeakerLabel,
|
|
286
302
|
gameIdify,
|
|
287
303
|
isCaseOnlyPropertyName,
|
package/dist/index.d.cts
CHANGED
|
@@ -431,6 +431,17 @@ declare const DEFAULT_PAD_AFTER = 0.6;
|
|
|
431
431
|
/** The range validation keeps a `padAfter` or `padAfterDefault` within, in seconds. */
|
|
432
432
|
declare const PAD_AFTER_MIN = -10;
|
|
433
433
|
declare const PAD_AFTER_MAX = 60;
|
|
434
|
+
/** The reading rate a line with no recording is timed by, in characters a second (`estimateLineDuration`). */
|
|
435
|
+
declare const LINE_CHARS_PER_SECOND = 14;
|
|
436
|
+
/** The shortest and longest a line with no recording lasts, in seconds (`estimateLineDuration`). */
|
|
437
|
+
declare const LINE_DURATION_MIN = 1.5;
|
|
438
|
+
declare const LINE_DURATION_MAX = 18;
|
|
439
|
+
/** How long a line with no recording lasts, in seconds: its characters at 14 a second, clamped to 1.5 to 18
|
|
440
|
+
* seconds. A character is a Unicode code point (one outside the Basic Multilingual Plane counts once), and soft
|
|
441
|
+
* hyphens (U+00AD) aren't counted. This is the one rule every Patter tool and runtime times a line by: Patterpad's
|
|
442
|
+
* Play window, the playable HTML page, and the Unity, Unreal, and Godot runtimes, which the conformance corpus
|
|
443
|
+
* holds to the same numbers. `locale` is reserved for per-language reading rates and is unused for now. */
|
|
444
|
+
declare function estimateLineDuration(text: string, _locale?: string): number;
|
|
434
445
|
/** A qualifier as it reaches a compiled bundle: its `gameId` and authored name (the unlocalised fallback). */
|
|
435
446
|
interface BundleQualifier {
|
|
436
447
|
gameId: string;
|
|
@@ -1401,4 +1412,4 @@ interface ExtensionFieldDecl {
|
|
|
1401
1412
|
/** A node's extension values in a bundle: extension id -> field -> value, raw. */
|
|
1402
1413
|
type NodeExtensions = Record<string, Record<string, unknown>>;
|
|
1403
1414
|
|
|
1404
|
-
export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, COMMON_GENDERS, type CaptionDelimiters, type CastMember, type Comment, type CommentMessage, type CommentRange, type CompiledBlock, type CompiledEffect, type CompiledGroup, type CompiledScene, type CompiledSnippet, type CoverageDriver, DEFAULT_CAPTION_CHARACTER, DEFAULT_CAPTION_DELIMITERS, DEFAULT_DOCUMENTATION_CLASSES, DEFAULT_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, STRINGS_SCHEMA, type SaveEnvelope, type SaveGame, type SaveGameV3, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type SpeakerQualifier, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, formatSpeakerLabel, isContentlessBeat, isDialogueScene, projectLayout, projectQualifiers, qualifierStringKey, resolveSceneRef, sceneAddressIndex, speakerLabelKey, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
|
|
1415
|
+
export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, COMMON_GENDERS, type CaptionDelimiters, type CastMember, type Comment, type CommentMessage, type CommentRange, type CompiledBlock, type CompiledEffect, type CompiledGroup, type CompiledScene, type CompiledSnippet, type CoverageDriver, DEFAULT_CAPTION_CHARACTER, DEFAULT_CAPTION_DELIMITERS, DEFAULT_DOCUMENTATION_CLASSES, DEFAULT_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, LINE_CHARS_PER_SECOND, LINE_DURATION_MAX, LINE_DURATION_MIN, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, STRINGS_SCHEMA, type SaveEnvelope, type SaveGame, type SaveGameV3, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type SpeakerQualifier, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, estimateLineDuration, formatSpeakerLabel, isContentlessBeat, isDialogueScene, projectLayout, projectQualifiers, qualifierStringKey, resolveSceneRef, sceneAddressIndex, speakerLabelKey, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
|
package/dist/index.d.ts
CHANGED
|
@@ -431,6 +431,17 @@ declare const DEFAULT_PAD_AFTER = 0.6;
|
|
|
431
431
|
/** The range validation keeps a `padAfter` or `padAfterDefault` within, in seconds. */
|
|
432
432
|
declare const PAD_AFTER_MIN = -10;
|
|
433
433
|
declare const PAD_AFTER_MAX = 60;
|
|
434
|
+
/** The reading rate a line with no recording is timed by, in characters a second (`estimateLineDuration`). */
|
|
435
|
+
declare const LINE_CHARS_PER_SECOND = 14;
|
|
436
|
+
/** The shortest and longest a line with no recording lasts, in seconds (`estimateLineDuration`). */
|
|
437
|
+
declare const LINE_DURATION_MIN = 1.5;
|
|
438
|
+
declare const LINE_DURATION_MAX = 18;
|
|
439
|
+
/** How long a line with no recording lasts, in seconds: its characters at 14 a second, clamped to 1.5 to 18
|
|
440
|
+
* seconds. A character is a Unicode code point (one outside the Basic Multilingual Plane counts once), and soft
|
|
441
|
+
* hyphens (U+00AD) aren't counted. This is the one rule every Patter tool and runtime times a line by: Patterpad's
|
|
442
|
+
* Play window, the playable HTML page, and the Unity, Unreal, and Godot runtimes, which the conformance corpus
|
|
443
|
+
* holds to the same numbers. `locale` is reserved for per-language reading rates and is unused for now. */
|
|
444
|
+
declare function estimateLineDuration(text: string, _locale?: string): number;
|
|
434
445
|
/** A qualifier as it reaches a compiled bundle: its `gameId` and authored name (the unlocalised fallback). */
|
|
435
446
|
interface BundleQualifier {
|
|
436
447
|
gameId: string;
|
|
@@ -1401,4 +1412,4 @@ interface ExtensionFieldDecl {
|
|
|
1401
1412
|
/** A node's extension values in a bundle: extension id -> field -> value, raw. */
|
|
1402
1413
|
type NodeExtensions = Record<string, Record<string, unknown>>;
|
|
1403
1414
|
|
|
1404
|
-
export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, COMMON_GENDERS, type CaptionDelimiters, type CastMember, type Comment, type CommentMessage, type CommentRange, type CompiledBlock, type CompiledEffect, type CompiledGroup, type CompiledScene, type CompiledSnippet, type CoverageDriver, DEFAULT_CAPTION_CHARACTER, DEFAULT_CAPTION_DELIMITERS, DEFAULT_DOCUMENTATION_CLASSES, DEFAULT_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, STRINGS_SCHEMA, type SaveEnvelope, type SaveGame, type SaveGameV3, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type SpeakerQualifier, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, formatSpeakerLabel, isContentlessBeat, isDialogueScene, projectLayout, projectQualifiers, qualifierStringKey, resolveSceneRef, sceneAddressIndex, speakerLabelKey, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
|
|
1415
|
+
export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, COMMON_GENDERS, type CaptionDelimiters, type CastMember, type Comment, type CommentMessage, type CommentRange, type CompiledBlock, type CompiledEffect, type CompiledGroup, type CompiledScene, type CompiledSnippet, type CoverageDriver, DEFAULT_CAPTION_CHARACTER, DEFAULT_CAPTION_DELIMITERS, DEFAULT_DOCUMENTATION_CLASSES, DEFAULT_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, LINE_CHARS_PER_SECOND, LINE_DURATION_MAX, LINE_DURATION_MIN, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, STRINGS_SCHEMA, type SaveEnvelope, type SaveGame, type SaveGameV3, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type SpeakerQualifier, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, estimateLineDuration, formatSpeakerLabel, isContentlessBeat, isDialogueScene, projectLayout, projectQualifiers, qualifierStringKey, resolveSceneRef, sceneAddressIndex, speakerLabelKey, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
|
package/dist/index.js
CHANGED
|
@@ -103,6 +103,14 @@ function textIsAction(project, scene) {
|
|
|
103
103
|
var DEFAULT_PAD_AFTER = 0.6;
|
|
104
104
|
var PAD_AFTER_MIN = -10;
|
|
105
105
|
var PAD_AFTER_MAX = 60;
|
|
106
|
+
var LINE_CHARS_PER_SECOND = 14;
|
|
107
|
+
var LINE_DURATION_MIN = 1.5;
|
|
108
|
+
var LINE_DURATION_MAX = 18;
|
|
109
|
+
function estimateLineDuration(text, _locale) {
|
|
110
|
+
let count = 0;
|
|
111
|
+
for (const ch of text ?? "") if (ch !== "\xAD") count++;
|
|
112
|
+
return Math.min(Math.max(count / LINE_CHARS_PER_SECOND, LINE_DURATION_MIN), LINE_DURATION_MAX);
|
|
113
|
+
}
|
|
106
114
|
var DEFAULT_WRITING_STATUSES = [
|
|
107
115
|
{ name: "stub", colour: 0 },
|
|
108
116
|
// red
|
|
@@ -195,6 +203,9 @@ export {
|
|
|
195
203
|
EXTENSION_SHARD,
|
|
196
204
|
FLOW_SCHEMA,
|
|
197
205
|
HANDOFF_SCHEMA,
|
|
206
|
+
LINE_CHARS_PER_SECOND,
|
|
207
|
+
LINE_DURATION_MAX,
|
|
208
|
+
LINE_DURATION_MIN,
|
|
198
209
|
MANIFEST_EXTENSION,
|
|
199
210
|
PAD_AFTER_MAX,
|
|
200
211
|
PAD_AFTER_MIN,
|
|
@@ -212,6 +223,7 @@ export {
|
|
|
212
223
|
castStringKey,
|
|
213
224
|
deriveRecordingFolders,
|
|
214
225
|
effectiveGameId,
|
|
226
|
+
estimateLineDuration,
|
|
215
227
|
formatSpeakerLabel,
|
|
216
228
|
gameIdify,
|
|
217
229
|
isCaseOnlyPropertyName,
|
package/package.json
CHANGED