@makefully/dutifully 1.12.0 → 1.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.13.0
4
+
5
+ - Add `packfully` service client for packing images into texture atlases.
6
+
7
+ ## 1.12.1
8
+
9
+ - Preserve optional script-line `events` through Transcript for timed marker definitions.
10
+
3
11
  ## 1.12.0
4
12
 
5
13
  - Treat missing `src`/`output` directories as empty instead of failing; create output directories when writing.
package/README.md CHANGED
@@ -40,7 +40,7 @@ cheerfully({
40
40
  });
41
41
  ```
42
42
 
43
- ## Say (spoken notifications)
43
+ ### Say (spoken notifications)
44
44
 
45
45
  `say` generates short spoken phrases through Cheerfully's ElevenLabs service, caches the audio under `.cache/tts/`, and plays it locally via `node-web-audio-api`. Use it from npm scripts instead of wiring ElevenLabs into the consuming project:
46
46
 
@@ -109,6 +109,51 @@ This audio file process accepts ffmpeg commandline arguments to perform operatio
109
109
  }
110
110
  ```
111
111
 
112
+ ### Packfully
113
+
114
+ This image-to-atlas service packs PNG/JPG/WebP sprites into texture atlases and downloads atlas PNG(s) plus descriptor file(s).
115
+
116
+ ```javascript
117
+ {
118
+ "packfully": [{
119
+ "format": "texturepacker",
120
+ "src": "./example/sprites/",
121
+ "output": "./example/atlases/",
122
+ "options": {
123
+ "maxWidth": 2048,
124
+ "maxHeight": 2048,
125
+ "pot": true,
126
+ "smart": true,
127
+ "square": false,
128
+ "padding": 1,
129
+ "extrude": 1,
130
+ "border": 1,
131
+ "allowRotation": false,
132
+ "trim": true,
133
+ "trimThreshold": 0,
134
+ "prefix": "packed",
135
+ "scale": 1
136
+ },
137
+ "files": {
138
+ "hero.png": { "trim": false }
139
+ }
140
+ }]
141
+ }
142
+ ```
143
+
144
+ Use `exports: ["texturepacker", "createjs"]` (or `format`) to choose one or more atlas descriptors. Supported formats:
145
+
146
+ * `texturepacker` / `json-hash` / `pixi` / `phaser-hash` — TexturePacker JSON Hash
147
+ * `json-array` / `phaser-array` — TexturePacker JSON Array
148
+ * `createjs` / `easeljs` — CreateJS SpriteSheet JSON
149
+ * `spine` — Spine `.atlas` text
150
+ * `css` — CSS sprite classes
151
+ * `starling` / `sparrow` — Starling/Sparrow XML
152
+ * `unity` — Unity-oriented JSON
153
+ * `godot` — Godot atlas JSON
154
+
155
+ Spacing: `padding` is empty gap beyond `extrude`; `extrude` is edge-pixel bleed into that gap; `border` is margin from the atlas edge.
156
+
112
157
  ### Polly
113
158
 
114
159
  This text-to-voice service requires a script as input and will download audio VO generated by Amazon Polly. You can set Polly settings in `cheerfully.json` like so:
@@ -205,9 +250,17 @@ If your scripts include any phrases that should remain unbroken by the captionin
205
250
 
206
251
  Script lines may include an optional `class` (for example `"title"` or `"stage"`). In VTT exports this becomes a cue class span (`<c.title>…</c>`). In SAMI/SMI the paragraph `Class` is the job language plus `CC` (for example `ENUSCC` for `en-US`); when a speaker and/or script `class` is present, the dialog is wrapped in `<SPAN Class="…">` (for example `Class="todd stage"`). In JSON exports it is included on each caption entry. SRT, LRC, and MP3 SYLT ignore it.
207
252
 
253
+ Script lines may also include an optional `events` array for one-shot timed markers. Entries may be:
254
+
255
+ * a **number** — add to the running absolute time offset (ms)
256
+ * a **string** `"<phrase"` / `">phrase"` — set the offset to just before/after that phrase in the caption; any other string fires that event at the current offset
257
+ * an **object** `{ "event", "time"?, "before"?, "after"? }` — fires `event`; optional fields set the absolute offset (`time` wins over `before` over `after`)
258
+
259
+ Cheerfully resolves these against caption timings and exports them in parallel using the same caption `format` (`events.json`, `{id}.events.vtt` / `.srt` / `.sami` / `.smi` / `.lrc`, or a separate MP3 SYLT frame with content type `EVENTS` labeled `"events"`).
260
+
208
261
  ## Example
209
262
 
210
- Find an example script in the `./examples/` folder. You can run either `npm run test-elevenlabs` or `npm run test-polly` to create VO tracks in the examples folder that you can then use to try out `npm run test-rhubarb` and `npm run test-transcription`.
263
+ Find an example script in the `./examples/` folder. You can run either `npm run test-elevenlabs` or `npm run test-polly` to create VO tracks in the examples folder that you can then use to try out `npm run test-rhubarb` and `npm run test-transcription`. Sample sprites for atlas packing are under `./example/sprites/`; run `npm run test-packfully` to pack them into `./example/atlases/`.
211
264
 
212
265
  These examples are specified using a JSON definition in `./cheerfully.json` which you can copy or modify to set different generation parameters as supported by Cheerfully.
213
266
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makefully/dutifully",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "Client tools for Cheerfully service.",
5
5
  "main": "./src/index.js",
6
6
  "bin": {
@@ -19,6 +19,7 @@
19
19
  "test-allosaurus": "node ./cheer.js -service allosaurus",
20
20
  "test-elevenlabs": "node ./cheer.js -service elevenlabs",
21
21
  "test-ffmpeg": "node ./cheer.js -service ffmpeg",
22
+ "test-packfully": "node ./cheer.js -service packfully",
22
23
  "test-polly": "node ./cheer.js -service polly",
23
24
  "test-rasterize": "node ./cheer.js -service rasterize",
24
25
  "test-rhubarb": "node ./cheer.js -service rhubarb",
@@ -41,7 +42,10 @@
41
42
  "polly",
42
43
  "lipsync",
43
44
  "transcription",
44
- "captions"
45
+ "captions",
46
+ "packfully",
47
+ "atlas",
48
+ "spritesheet"
45
49
  ],
46
50
  "author": "Derek Detweiler <derek@makefullystudios.com>",
47
51
  "contributors": [
@@ -0,0 +1,15 @@
1
+ const
2
+ Cheer = require('./Cheer'),
3
+ Packfully = class Packfully extends Cheer {
4
+ beforeSend (archive) {
5
+ const
6
+ {src} = this.config;
7
+
8
+ if (src) {
9
+ archive.directory(src, false);
10
+ }
11
+ super.beforeSend(archive);
12
+ }
13
+ };
14
+
15
+ module.exports = Packfully;
@@ -41,7 +41,7 @@ const
41
41
  }
42
42
 
43
43
  const
44
- {caption, class: lineClass, speaker, voice} = line,
44
+ {caption, class: lineClass, speaker, voice, events} = line,
45
45
  resolvedVoice = voice ?? (voiceOrVoiceMap ? resolveVoice(voiceOrVoiceMap, speaker) : null),
46
46
  result = {caption};
47
47
 
@@ -53,6 +53,10 @@ const
53
53
  result.speaker = speaker;
54
54
  }
55
55
 
56
+ if (events) {
57
+ result.events = events;
58
+ }
59
+
56
60
  if (resolvedVoice) {
57
61
  result.voice = resolvedVoice;
58
62
  }
package/src/index.js CHANGED
@@ -6,6 +6,7 @@ const
6
6
  allosaurus: LipSync,
7
7
  elevenlabs: require('./classes/ElevenLabs'),
8
8
  ffmpeg: require('./classes/FFMPEG'),
9
+ packfully: require('./classes/Packfully'),
9
10
  polly: require('./classes/Polly'),
10
11
  rasterize: require('./classes/Rasterize'),
11
12
  rhubarb: LipSync,