@domicile-desktop/component-library 0.0.0-alpha-e77cfff77793 → 0.0.0-alpha-5166c4cfb4be

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/vite-shell.ts +32 -3
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "dependencies": {
3
3
  "@base-ui/react": "^1.8.0",
4
4
  "@cprussin/option-result": "^2.0.1",
5
- "@domicile-desktop/sdk": "0.0.0-alpha-e77cfff77793",
6
- "@domicile-desktop/system-apps": "0.0.0-alpha-e77cfff77793",
5
+ "@domicile-desktop/sdk": "0.0.0-alpha-5166c4cfb4be",
6
+ "@domicile-desktop/system-apps": "0.0.0-alpha-5166c4cfb4be",
7
7
  "@pandacss/dev": "^1.12.1",
8
8
  "@phosphor-icons/react": "^2.1.10"
9
9
  },
@@ -109,5 +109,5 @@
109
109
  "test:unit": "bun test"
110
110
  },
111
111
  "type": "module",
112
- "version": "0.0.0-alpha-e77cfff77793"
112
+ "version": "0.0.0-alpha-5166c4cfb4be"
113
113
  }
package/src/vite-shell.ts CHANGED
@@ -7,7 +7,8 @@
7
7
  // render but module scripts are deferred, so the page would paint before the
8
8
  // shell applies its theme.
9
9
 
10
- import type { Plugin } from "vite";
10
+ import type { Options } from "@domicile-desktop/sdk/options";
11
+ import type { Plugin, Rollup } from "vite";
11
12
 
12
13
  /**
13
14
  * Moves the CSS assets vite extracted into the entry chunk as a `<style>`.
@@ -58,13 +59,23 @@ export type ShellBuild = {
58
59
  readonly entry: string;
59
60
  /** The module's file name; `shell.js` by default. An app names its own. */
60
61
  readonly fileName?: string;
62
+ /**
63
+ * The shell's `options` export, written to `options.json` beside the module
64
+ * for the Settings app, as the builder does for a config's shell. See
65
+ * `docs/WRITING-A-SHELL.md#options`.
66
+ */
67
+ readonly options?: Options;
61
68
  };
62
69
 
63
70
  /**
64
71
  * The `build` and `plugins` a shell's vite config needs. Spread it into the
65
72
  * shell's own config.
66
73
  */
67
- export const shellBuild = ({ entry, fileName = "shell.js" }: ShellBuild) => ({
74
+ export const shellBuild = ({
75
+ entry,
76
+ fileName = "shell.js",
77
+ options,
78
+ }: ShellBuild) => ({
68
79
  build: {
69
80
  // No content hash, so configs and packages can name the module path.
70
81
  //
@@ -77,5 +88,23 @@ export const shellBuild = ({ entry, fileName = "shell.js" }: ShellBuild) => ({
77
88
  },
78
89
  sourcemap: true,
79
90
  },
80
- plugins: [cssInTheModule()],
91
+ plugins: [
92
+ cssInTheModule(),
93
+ ...(options === undefined ? [] : [shellOptions(options)]),
94
+ ],
95
+ });
96
+
97
+ /** `options.json`, as the builder writes it beside a shell's module. */
98
+ export const optionsAsset = (options: Options): Rollup.EmittedAsset => ({
99
+ fileName: "options.json",
100
+ source: `${JSON.stringify(options)}\n`,
101
+ type: "asset",
102
+ });
103
+
104
+ /** Writes `options` to `options.json` beside the module. */
105
+ const shellOptions = (options: Options): Plugin => ({
106
+ generateBundle() {
107
+ this.emitFile(optionsAsset(options));
108
+ },
109
+ name: "domicile:shell-options",
81
110
  });