@patterkit/model 0.1.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 +120 -0
- package/dist/index.d.cts +782 -0
- package/dist/index.d.ts +782 -0
- package/dist/index.js +83 -0
- package/package.json +30 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function walkNodes(nodes, visit) {
|
|
3
|
+
for (const node of nodes) {
|
|
4
|
+
visit(node);
|
|
5
|
+
const children = node.children;
|
|
6
|
+
if (children) walkNodes(children, visit);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function isContentlessBeat(beat, hasText) {
|
|
10
|
+
if (beat.kind === "gameEvent") return false;
|
|
11
|
+
if (hasText) return false;
|
|
12
|
+
if (beat.gameData && Object.keys(beat.gameData).length > 0) return false;
|
|
13
|
+
if (beat.tags && beat.tags.length > 0) return false;
|
|
14
|
+
return beat.kind === "text" || !beat.character && !beat.direction;
|
|
15
|
+
}
|
|
16
|
+
function gameIdify(text) {
|
|
17
|
+
return text.toLowerCase().replace(/['’]/g, "").replace(/[^a-z0-9-]+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
18
|
+
}
|
|
19
|
+
function isValidGameId(gameId) {
|
|
20
|
+
return /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(gameId);
|
|
21
|
+
}
|
|
22
|
+
function effectiveGameId(entity) {
|
|
23
|
+
const g = entity.gameId?.trim();
|
|
24
|
+
return g ? g : gameIdify(entity.name);
|
|
25
|
+
}
|
|
26
|
+
var DEFAULT_WRITING_STATUSES = [
|
|
27
|
+
{ name: "stub", colour: 0 },
|
|
28
|
+
// red
|
|
29
|
+
{ name: "draft 1", colour: 1 },
|
|
30
|
+
// rust
|
|
31
|
+
{ name: "draft 2", colour: 2 },
|
|
32
|
+
// ochre
|
|
33
|
+
{ name: "edited", readyToRecord: true, colour: 4 },
|
|
34
|
+
// green
|
|
35
|
+
{ name: "final", readyToShip: true, colour: 9 }
|
|
36
|
+
// purple (violet)
|
|
37
|
+
];
|
|
38
|
+
var DEFAULT_RECORDING_STATUSES = [
|
|
39
|
+
{ name: "missing", colour: 0 },
|
|
40
|
+
// red
|
|
41
|
+
{ name: "scratch", colour: 2 },
|
|
42
|
+
// ochre
|
|
43
|
+
{ name: "recorded", colour: 4 },
|
|
44
|
+
// green
|
|
45
|
+
{ name: "final", colour: 9 }
|
|
46
|
+
// purple
|
|
47
|
+
];
|
|
48
|
+
function deriveRecordingFolders(audioRoot, statuses) {
|
|
49
|
+
const root = audioRoot?.trim();
|
|
50
|
+
return statuses.map((s, i) => {
|
|
51
|
+
if (i === 0 || !root) return { name: s.name };
|
|
52
|
+
return { name: s.name, folder: `${root}/${gameIdify(s.name)}` };
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
var DEFAULT_DOCUMENTATION_CLASSES = [
|
|
56
|
+
{ name: "everyone", deliver: "*" },
|
|
57
|
+
// every export, and (like all) the editor
|
|
58
|
+
{ name: "vo", deliver: ["vo"] },
|
|
59
|
+
// voice-recording scripts
|
|
60
|
+
{ name: "loc", deliver: ["loc"] }
|
|
61
|
+
// localisation handoff
|
|
62
|
+
];
|
|
63
|
+
var PROJECT_LOCALE_SCENE = "@project";
|
|
64
|
+
function castStringKey(name) {
|
|
65
|
+
return `cast:${name}`;
|
|
66
|
+
}
|
|
67
|
+
var DEFAULT_CAPTION_DELIMITERS = { open: "[", close: "]" };
|
|
68
|
+
var DEFAULT_CAPTION_CHARACTER = "SFX";
|
|
69
|
+
export {
|
|
70
|
+
DEFAULT_CAPTION_CHARACTER,
|
|
71
|
+
DEFAULT_CAPTION_DELIMITERS,
|
|
72
|
+
DEFAULT_DOCUMENTATION_CLASSES,
|
|
73
|
+
DEFAULT_RECORDING_STATUSES,
|
|
74
|
+
DEFAULT_WRITING_STATUSES,
|
|
75
|
+
PROJECT_LOCALE_SCENE,
|
|
76
|
+
castStringKey,
|
|
77
|
+
deriveRecordingFolders,
|
|
78
|
+
effectiveGameId,
|
|
79
|
+
gameIdify,
|
|
80
|
+
isContentlessBeat,
|
|
81
|
+
isValidGameId,
|
|
82
|
+
walkNodes
|
|
83
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@patterkit/model",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Patter data-model types: source (scene/block/group/snippet/beat/jump), project, locale, authoring. The shape source-of-truth.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Ian Thomas",
|
|
8
|
+
"homepage": "https://patterkit.dev",
|
|
9
|
+
"repository": { "type": "git", "url": "git+https://github.com/patterkit/patter.git", "directory": "packages/model" },
|
|
10
|
+
"bugs": "https://github.com/patterkit/patter/issues",
|
|
11
|
+
"publishConfig": { "access": "public" },
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": ["dist", "README.md"],
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@wildwinter/expr": "^0.3.0"
|
|
29
|
+
}
|
|
30
|
+
}
|