@gannochenko/staticstripes 0.0.17 → 0.0.19

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/src/project.ts CHANGED
@@ -12,6 +12,7 @@ import { Sequence } from './sequence';
12
12
  import { FilterBuffer } from './stream';
13
13
  import { ExpressionContext, FragmentData } from './expression-parser';
14
14
  import { renderContainers } from './container-renderer';
15
+ import { renderApps } from './app-renderer';
15
16
  import { dirname } from 'path';
16
17
 
17
18
  export class Project {
@@ -27,6 +28,7 @@ export class Project {
27
28
  private aiProviders: Map<string, AIProvider>,
28
29
  private title: string,
29
30
  private date: string | undefined,
31
+ private tags: string[],
30
32
  private cssText: string,
31
33
  private projectPath: string,
32
34
  ) {
@@ -146,6 +148,10 @@ export class Project {
146
148
  return this.date;
147
149
  }
148
150
 
151
+ public getTags(): string[] {
152
+ return this.tags;
153
+ }
154
+
149
155
  public getCssText(): string {
150
156
  return this.cssText;
151
157
  }
@@ -212,6 +218,72 @@ export class Project {
212
218
  return this.assetManager.getAudioInputLabelByAssetName(name);
213
219
  }
214
220
 
221
+ /**
222
+ * Renders all apps and creates virtual assets for them.
223
+ * Apps must dispatch "sts-render-complete" on document when ready,
224
+ * or rendering will fail after a 5-second timeout.
225
+ */
226
+ public async renderApps(
227
+ outputName: string,
228
+ activeCacheKeys?: Set<string>,
229
+ ): Promise<void> {
230
+ const output = this.getOutput(outputName);
231
+ if (!output) {
232
+ throw new Error(`Output "${outputName}" not found`);
233
+ }
234
+
235
+ const fragmentsWithApps = this.sequencesDefinitions.flatMap((seq) =>
236
+ seq.fragments.filter((frag) => frag.app),
237
+ );
238
+
239
+ if (fragmentsWithApps.length === 0) {
240
+ return;
241
+ }
242
+
243
+ console.log('\n=== Rendering Apps ===\n');
244
+
245
+ const apps = fragmentsWithApps.map((frag) => frag.app!);
246
+ const projectDir = dirname(this.projectPath);
247
+
248
+ const results = await renderApps(
249
+ apps,
250
+ output.resolution.width,
251
+ output.resolution.height,
252
+ projectDir,
253
+ outputName,
254
+ this.title,
255
+ this.date,
256
+ this.tags,
257
+ activeCacheKeys,
258
+ );
259
+
260
+ // Create virtual assets and update fragment assetNames
261
+ for (const result of results) {
262
+ const virtualAssetName = result.app.id;
263
+
264
+ const virtualAsset = {
265
+ name: virtualAssetName,
266
+ path: result.screenshotPath,
267
+ type: 'image' as const,
268
+ duration: 0,
269
+ width: output.resolution.width,
270
+ height: output.resolution.height,
271
+ rotation: 0,
272
+ hasVideo: true,
273
+ hasAudio: false,
274
+ };
275
+
276
+ this.assetManager.addVirtualAsset(virtualAsset);
277
+
278
+ const fragment = fragmentsWithApps.find(
279
+ (frag) => frag.app?.id === result.app.id,
280
+ );
281
+ if (fragment) {
282
+ fragment.assetName = virtualAssetName;
283
+ }
284
+ }
285
+ }
286
+
215
287
  /**
216
288
  * Renders all containers and creates virtual assets for them
217
289
  */
package/src/type.ts CHANGED
@@ -13,6 +13,12 @@ export type Container = {
13
13
  htmlContent: string;
14
14
  };
15
15
 
16
+ export type App = {
17
+ id: string;
18
+ src: string; // path to the app's dst directory (relative to project)
19
+ parameters: Record<string, string>; // extra params from data-parameters
20
+ };
21
+
16
22
  export type ParsedHtml = {
17
23
  ast: Document;
18
24
  css: Map<Element, CSSProperties>;
@@ -61,6 +67,7 @@ export type Fragment = {
61
67
  chromakeyColor: string;
62
68
  visualFilter?: string; // Optional visual filter (e.g., 'instagram-nashville')
63
69
  container?: Container; // Optional container attached to this fragment
70
+ app?: App; // Optional app attached to this fragment
64
71
  timecodeLabel?: string; // Optional label for timecode (from data-timecode attribute)
65
72
  };
66
73