@hadoku/ui-shell 0.1.126 → 0.1.127

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.
@@ -1,3 +1,4 @@
1
+ import { type ExternalGameManifestInput } from '@wolffm/platform-wire/external-game-manifest';
1
2
  /** `:root` / `html` / `body` as a compound's type or pseudo-class → `:host`. */
2
3
  export declare function toShadowSelector(selector: string): string;
3
4
  /** A bare `[data-theme…]` selector also matches the host carrying it. Idempotent — postcss revisits a changed rule. */
@@ -17,7 +18,20 @@ export declare function shadowRootSelectors({ hostTheme }?: {
17
18
  export declare function embedFiles(app: string): {
18
19
  entry: string;
19
20
  stylesheet: string;
21
+ manifest: string;
20
22
  };
23
+ export interface EmbedManifestPlugin {
24
+ name: string;
25
+ generateBundle(this: {
26
+ emitFile(file: {
27
+ type: 'asset';
28
+ fileName: string;
29
+ source: string;
30
+ }): string;
31
+ }): void;
32
+ }
33
+ /** Writes the game's manifest beside the entry, after checking it is one a host would read. */
34
+ export declare function emitManifest(fileName: string, manifest: ExternalGameManifestInput): EmbedManifestPlugin;
21
35
  export interface OneStylesheetPlugin {
22
36
  name: string;
23
37
  writeBundle(this: {
@@ -43,14 +57,16 @@ export interface EmbedBuildOptions<Warn, Output extends object, Post> {
43
57
  onwarn?: Warn;
44
58
  /** More of the bundler's output options (cardtable's chunk groups); the file names are the preset's. */
45
59
  output?: Output;
60
+ /** What a host reads to make this game a room type; written as `embed/manifest.json`. Absent, no manifest is written. */
61
+ manifest?: ExternalGameManifestInput;
46
62
  }
47
63
  /**
48
64
  * The embed build's config. Spread it into `defineConfig`, and put the game's own plugins (React)
49
65
  * before `preset.plugins`.
50
66
  */
51
- export declare function embedBuild<Warn = never, Output extends object = Record<never, never>, Post = never>({ app, base, input, hostTheme, postcssPlugins, sourcemap, target, chunkSizeWarningLimit, onwarn, output, }: EmbedBuildOptions<Warn, Output, Post>): {
67
+ export declare function embedBuild<Warn = never, Output extends object = Record<never, never>, Post = never>({ app, base, input, hostTheme, postcssPlugins, sourcemap, target, chunkSizeWarningLimit, onwarn, output, manifest, }: EmbedBuildOptions<Warn, Output, Post>): {
52
68
  base: string;
53
- plugins: OneStylesheetPlugin[];
69
+ plugins: (EmbedManifestPlugin | OneStylesheetPlugin)[];
54
70
  css: {
55
71
  postcss: {
56
72
  plugins: (ShadowRootSelectorsPlugin | Post)[];
@@ -24,7 +24,12 @@
24
24
  * mount stamps the theme on the host (`mountEmbed`'s `hostTheme`). Without it the host painted the
25
25
  * light background under every theme, a white flash between the sheet's adoption and React's first
26
26
  * commit. Cardtable's.
27
+ * - **`manifest`: what the game says about itself to a host** (`@hadoku/platform-wire/external-game-manifest`:
28
+ * its name, its seat range, its seat hold), written as `dist/embed/manifest.json` beside the entry
29
+ * and served `no-cache` like it. Checked against the host's own schema here, so a manifest a host
30
+ * would refuse fails this build instead.
27
31
  */
32
+ import { EXTERNAL_GAME_MANIFEST_FILE, externalGameManifest, } from '@wolffm/platform-wire/external-game-manifest';
28
33
  /** `:root` / `html` / `body` as a compound's type or pseudo-class → `:host`. */
29
34
  export function toShadowSelector(selector) {
30
35
  return selector.replace(/:root\b/g, ':host').replace(/(^|[\s,>+~(])(?:html|body)(?![\w-])/g, '$1:host');
@@ -51,7 +56,20 @@ export function shadowRootSelectors({ hostTheme = false } = {}) {
51
56
  }
52
57
  /** The fixed names the bundle is served under. */
53
58
  export function embedFiles(app) {
54
- return { entry: `embed/${app}-embed.js`, stylesheet: `embed/${app}-embed.css` };
59
+ return { entry: `embed/${app}-embed.js`, stylesheet: `embed/${app}-embed.css`, manifest: `embed/${EXTERNAL_GAME_MANIFEST_FILE}` };
60
+ }
61
+ /** Writes the game's manifest beside the entry, after checking it is one a host would read. */
62
+ export function emitManifest(fileName, manifest) {
63
+ const checked = externalGameManifest.safeParse(manifest);
64
+ if (!checked.success)
65
+ throw new Error(`the embed manifest is not one a host would read: ${checked.error.issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`).join('; ')}`);
66
+ const source = `${JSON.stringify(checked.data, null, 2)}\n`;
67
+ return {
68
+ name: 'embed-manifest',
69
+ generateBundle() {
70
+ this.emitFile({ type: 'asset', fileName, source });
71
+ },
72
+ };
55
73
  }
56
74
  /** Fails the build if the one stylesheet did not come out under its fixed name. */
57
75
  export function requireOneStylesheet(stylesheet) {
@@ -69,11 +87,12 @@ export function requireOneStylesheet(stylesheet) {
69
87
  * The embed build's config. Spread it into `defineConfig`, and put the game's own plugins (React)
70
88
  * before `preset.plugins`.
71
89
  */
72
- export function embedBuild({ app, base, input = 'src/embed/index.tsx', hostTheme = false, postcssPlugins = [], sourcemap = false, target, chunkSizeWarningLimit, onwarn, output, }) {
73
- const { entry, stylesheet } = embedFiles(app);
90
+ export function embedBuild({ app, base, input = 'src/embed/index.tsx', hostTheme = false, postcssPlugins = [], sourcemap = false, target, chunkSizeWarningLimit, onwarn, output, manifest, }) {
91
+ const files = embedFiles(app);
92
+ const { entry, stylesheet } = files;
74
93
  return {
75
94
  base,
76
- plugins: [requireOneStylesheet(stylesheet)],
95
+ plugins: [requireOneStylesheet(stylesheet), ...(manifest === undefined ? [] : [emitManifest(files.manifest, manifest)])],
77
96
  css: { postcss: { plugins: [shadowRootSelectors({ hostTheme }), ...postcssPlugins] } },
78
97
  build: {
79
98
  outDir: 'dist',
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@hadoku/ui-shell",
3
- "version": "0.1.126",
4
- "gitHead": "757644312b0d7b18d58a830c2e74e4db7abc0b42",
3
+ "version": "0.1.127",
4
+ "gitHead": "39cb96a57f7c400e6390c22911b93618ef495ef5",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "description": "The parts of a game's UI any game keeps: chrome, trim, room shell, embed mount, theme and settings frame, UI scale, usage counting, the sound mixer, motion and generic components. One appId parameterizes its storage keys, events and chat prefix. MIT; imports only react, react-dom and @wolffm/*.",
7
+ "description": "The parts of a game's UI any game keeps: chrome, trim, room shell, embed mount, theme and settings frame, UI scale, usage counting, the sound mixer, motion and generic components. One appId parameterizes its storage keys, events and chat prefix. MIT; imports only react, react-dom, platform-wire and @wolffm/*.",
8
8
  "exports": {
9
9
  "./app-id": {
10
10
  "types": "./dist/app-id/index.d.ts",
@@ -60,6 +60,7 @@
60
60
  "react-dom": "^19.2.8"
61
61
  },
62
62
  "dependencies": {
63
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.127",
63
64
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.0",
64
65
  "@wolffm/themes": "npm:@hadoku/themes@^5.14.16",
65
66
  "zod": "4.5.4"