nucleus-core-ts 0.10.192 → 0.10.193
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/.build-ok +1 -1
- package/fe/components/DemoFilm/_types/clock.ts +34 -0
- package/fe/components/DemoFilm/_types/device.ts +21 -0
- package/fe/components/DemoFilm/_types/index.ts +6 -0
- package/fe/components/DemoFilm/_types/player.ts +20 -0
- package/fe/components/DemoFilm/_types/stage.ts +26 -0
- package/fe/components/DemoFilm/_types/theme.ts +42 -0
- package/fe/components/DemoFilm/_types/timeline.ts +56 -0
- package/package.json +2 -1
- package/scripts/demo-film/capture/index.ts +9 -0
- package/scripts/demo-film/index.ts +3 -3
- package/scripts/demo-film/pageGlobals.d.ts +8 -0
package/dist/.build-ok
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.10.
|
|
1
|
+
0.10.193
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DemoBeat, DemoTimeline } from './timeline'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The film clock: everything a composition may know about time. A composition renders purely from
|
|
5
|
+
* this and its props, so the same frame always paints the same picture (player, still or encode).
|
|
6
|
+
*/
|
|
7
|
+
export interface FilmClock {
|
|
8
|
+
/** The frame to paint, 0-based. */
|
|
9
|
+
frame: number
|
|
10
|
+
fps: number
|
|
11
|
+
durationInFrames: number
|
|
12
|
+
/** Composition size in px. */
|
|
13
|
+
width: number
|
|
14
|
+
height: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The timeline, asset base and language of the surrounding film. */
|
|
18
|
+
export interface DemoFilmValue<Role extends string = string> {
|
|
19
|
+
timeline: DemoTimeline<Role>
|
|
20
|
+
assetBase: string
|
|
21
|
+
locale: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Where in the film the current frame is. */
|
|
25
|
+
export interface BeatClock<Role extends string = string> {
|
|
26
|
+
frame: number
|
|
27
|
+
fps: number
|
|
28
|
+
index: number
|
|
29
|
+
beat: DemoBeat<Role>
|
|
30
|
+
/** Frames since this beat started. */
|
|
31
|
+
localFrame: number
|
|
32
|
+
/** Frames this beat lasts. */
|
|
33
|
+
beatFrames: number
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type DeviceKind = 'phone' | 'tablet' | 'browser'
|
|
2
|
+
|
|
3
|
+
/** Which device a role is shown on; a role without an entry is a browser window. */
|
|
4
|
+
export type DeviceMap<Role extends string> = Partial<Record<Role, DeviceKind>>
|
|
5
|
+
|
|
6
|
+
export interface DeviceChrome {
|
|
7
|
+
kind: DeviceKind
|
|
8
|
+
/** Bezel on the left, right and bottom. */
|
|
9
|
+
pad: number
|
|
10
|
+
/** Bezel above the screen (the browser's tab and address bar included). */
|
|
11
|
+
top: number
|
|
12
|
+
radius: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DeviceFit {
|
|
16
|
+
screenWidth: number
|
|
17
|
+
screenHeight: number
|
|
18
|
+
chrome: DeviceChrome
|
|
19
|
+
width: number
|
|
20
|
+
height: number
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** What a player tells its listeners. `frameupdate` fires whenever the shown frame changes. */
|
|
2
|
+
export type FilmPlayerEvent =
|
|
3
|
+
| { type: 'frameupdate'; detail: { frame: number } }
|
|
4
|
+
| { type: 'play' }
|
|
5
|
+
| { type: 'pause' }
|
|
6
|
+
| { type: 'ended' }
|
|
7
|
+
|
|
8
|
+
export type FilmPlayerListener = (event: FilmPlayerEvent) => void
|
|
9
|
+
|
|
10
|
+
/** The remote control of a FilmPlayer. */
|
|
11
|
+
export interface FilmPlayerHandle {
|
|
12
|
+
play: () => void
|
|
13
|
+
pause: () => void
|
|
14
|
+
/** Jump to a frame (clamped to the film); keeps playing if it was playing. */
|
|
15
|
+
seekTo: (frame: number) => void
|
|
16
|
+
getCurrentFrame: () => number
|
|
17
|
+
isPlaying: () => boolean
|
|
18
|
+
/** Returns the function that removes the listener. */
|
|
19
|
+
subscribe: (listener: FilmPlayerListener) => () => void
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DeviceMap } from './device'
|
|
2
|
+
import type { DemoFilmThemeOverride } from './theme'
|
|
3
|
+
import type { DemoText, DemoTimeline } from './timeline'
|
|
4
|
+
|
|
5
|
+
export interface RoleStageProps<Role extends string> {
|
|
6
|
+
timeline: DemoTimeline<Role>
|
|
7
|
+
role: Role
|
|
8
|
+
/** Where the run folder is served: a URL or an absolute path. */
|
|
9
|
+
assetBase: string
|
|
10
|
+
/** Caption language; defaults to the timeline's. */
|
|
11
|
+
locale?: string
|
|
12
|
+
/** Which device each role is shown on; a role without an entry is a browser window. */
|
|
13
|
+
devices?: DeviceMap<Role>
|
|
14
|
+
/** The address shown in each browser window's bar. */
|
|
15
|
+
addresses?: Partial<Record<Role, string>>
|
|
16
|
+
/** The words printed under a thumbnail (`compact`); the role's name when missing. */
|
|
17
|
+
labels?: Partial<Record<Role, DemoText>>
|
|
18
|
+
/** Palette and fonts instead of the defaults. */
|
|
19
|
+
theme?: DemoFilmThemeOverride
|
|
20
|
+
/** Pixel box to fill; defaults to the composition. */
|
|
21
|
+
box?: { width: number; height: number }
|
|
22
|
+
/** Part of a bigger scene (the film's thumbnails): no theme root, no caption. */
|
|
23
|
+
embedded?: boolean
|
|
24
|
+
/** Thumbnail look: no spotlight, a label under the device. */
|
|
25
|
+
compact?: boolean
|
|
26
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { DemoTheme } from './timeline'
|
|
2
|
+
|
|
3
|
+
/** The colours of one theme, painted as `--film-*` CSS variables on the film root. */
|
|
4
|
+
export interface DemoFilmPalette {
|
|
5
|
+
bg: string
|
|
6
|
+
surface: string
|
|
7
|
+
surface2: string
|
|
8
|
+
ink: string
|
|
9
|
+
soft: string
|
|
10
|
+
faint: string
|
|
11
|
+
line: string
|
|
12
|
+
accent: string
|
|
13
|
+
accentInk: string
|
|
14
|
+
onAccent: string
|
|
15
|
+
/** Full CSS `box-shadow` of a device. */
|
|
16
|
+
shadow: string
|
|
17
|
+
/** Phone and tablet bezel. */
|
|
18
|
+
bezel: string
|
|
19
|
+
bezelLine: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DemoFilmFonts {
|
|
23
|
+
display: string
|
|
24
|
+
sans: string
|
|
25
|
+
mono: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface DemoFilmTheme {
|
|
29
|
+
light: DemoFilmPalette
|
|
30
|
+
dark: DemoFilmPalette
|
|
31
|
+
fonts: DemoFilmFonts
|
|
32
|
+
/** Extra variables a product's own scenes use, by full custom-property name (`--film-slab`), per theme. */
|
|
33
|
+
extra?: Partial<Record<DemoTheme, Readonly<Record<string, string>>>>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** What a product passes to change the defaults; every group is merged key by key. */
|
|
37
|
+
export interface DemoFilmThemeOverride {
|
|
38
|
+
light?: Partial<DemoFilmPalette>
|
|
39
|
+
dark?: Partial<DemoFilmPalette>
|
|
40
|
+
fonts?: Partial<DemoFilmFonts>
|
|
41
|
+
extra?: DemoFilmTheme['extra']
|
|
42
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The demo timeline contract. A product writes one run (a `timeline.json` plus the captured frames),
|
|
3
|
+
* the film compositions read it. The contract is generic over the product's role names; anything a
|
|
4
|
+
* product adds (counters, acts, clocks) extends these interfaces in the product.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type DemoTheme = 'light' | 'dark'
|
|
8
|
+
|
|
9
|
+
/** One sentence per language, keyed by locale code (`{ en: '...', tr: '...' }`). */
|
|
10
|
+
export type DemoText = Readonly<Record<string, string>>
|
|
11
|
+
|
|
12
|
+
/** A box on the captured image, in the image's CSS pixels (before the device scale factor). */
|
|
13
|
+
export interface DemoBox {
|
|
14
|
+
x: number
|
|
15
|
+
y: number
|
|
16
|
+
w: number
|
|
17
|
+
h: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The viewport a role is captured at. */
|
|
21
|
+
export interface DemoViewport {
|
|
22
|
+
width: number
|
|
23
|
+
height: number
|
|
24
|
+
scale: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface DemoFrame {
|
|
28
|
+
/** Path relative to the run folder, e.g. `frames/b06-guest.webp`. */
|
|
29
|
+
image: string
|
|
30
|
+
highlight: DemoBox | null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface DemoBeat<Role extends string = string> {
|
|
34
|
+
/** Stable id, `b01` to `b99`. */
|
|
35
|
+
id: string
|
|
36
|
+
caption: DemoText
|
|
37
|
+
/** Only the roles whose screen changed in this beat; a player holds each role's last frame. */
|
|
38
|
+
frames: Partial<Record<Role, DemoFrame>>
|
|
39
|
+
/** The role the film shows for this beat. */
|
|
40
|
+
focus: Role
|
|
41
|
+
/** Seconds the film spends on this beat. */
|
|
42
|
+
seconds: number
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface DemoTimeline<Role extends string = string> {
|
|
46
|
+
version: 1
|
|
47
|
+
/** Default caption language. */
|
|
48
|
+
locale: string
|
|
49
|
+
theme: DemoTheme
|
|
50
|
+
/** True on a placeholder run: a public page never shows it. */
|
|
51
|
+
fixture?: boolean
|
|
52
|
+
/** ISO time of the run that produced the frames. */
|
|
53
|
+
recordedAt: string
|
|
54
|
+
viewports: Record<Role, DemoViewport>
|
|
55
|
+
beats: DemoBeat<Role>[]
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.193",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"dist",
|
|
16
16
|
"schemas",
|
|
17
17
|
"scripts",
|
|
18
|
+
"fe/components/DemoFilm/_types",
|
|
18
19
|
"infra/templates",
|
|
19
20
|
"infra/scripts/generate-project.ts",
|
|
20
21
|
"src/system.tables.json",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
/// <reference path="./pageGlobals.d.ts" />
|
|
1
2
|
/**
|
|
2
3
|
* `nucleus-core-ts/demo-film`: captures a demo run from the real product (`captureRun`, against its
|
|
3
4
|
* own UI and a fixture API from `createFixtureServer`), and renders demo films (the compositions an
|
|
4
5
|
* app builds from `nucleus-core-ts/fe`'s DemoFilm kit) to MP4 or PNG stills with headless Chrome.
|
|
5
|
-
* Server side only,
|
|
6
|
-
*
|
|
7
|
-
* app that renders.
|
|
6
|
+
* Server side only, run by Bun. `puppeteer-core` and `mp4-muxer` are optional peer dependencies:
|
|
7
|
+
* install them in the app that renders.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export * from './capture'
|
|
@@ -16,6 +16,14 @@ interface EncoderHost {
|
|
|
16
16
|
read: (offset: number, length: number) => string
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/** What a composition page offers (fe/components/DemoFilm/_host/types.ts DemoFilmHostApi, same shape). */
|
|
20
|
+
interface FilmPageHost {
|
|
21
|
+
readonly durationInFrames: number
|
|
22
|
+
seek: (frame: number) => Promise<void>
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
interface Window {
|
|
20
26
|
__encoder?: EncoderHost
|
|
27
|
+
__film?: FilmPageHost
|
|
28
|
+
__filmError?: string
|
|
21
29
|
}
|