// wayBetter for X's part of the shared wayBetter Store (app id "x"), for `waybetter store build` // (the framework CLI; `node scripts/build-store.mjs` runs it with the paths below). // // The items are the folders under store/x/ (one per item; layout in store/README.md, read by // scripts/store/source.mjs): a pull request that adds a folder adds an item. The build writes // plugins/.plugin.js the plugin exactly as its folder (or the app, for bundled ones) has it // themes/.json the theme file (built-in themes exported like Appearance → Export does) // previews/-.svg the folder's preview, else one drawn from the item (scripts/store/preview.mjs) // The first-party plugins are read from $WAYBETTER_STORE_PLUGINS when set (e.g. an export of // committed files), else from apps/desktop/src-tauri/bundled-plugins. import { dirname, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import { readStoreSource } from './store/source.mjs'; const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..'); export const APP = 'x'; /** The folders under store/x/ as build entries, with the problems that would stop a build. */ export async function source() { const { BUILTIN_THEMES } = await import('../apps/desktop/src/inject/themeSpec.ts'); const { THEME_SCHEMA_URL } = await import('../waybetter/packages/runtime/src/themeApi.ts'); const { sanitizeSpec } = await import('../waybetter/packages/runtime/src/themeSpec.ts'); const { X_TABLE } = await import('../apps/desktop/src/areas/table.ts'); const { supersededFiles } = await import('../waybetter/packages/runtime/src/featureTable.ts'); return readStoreSource({ // Bundled files a built-in feature replaced ("bt-.plugin.js" installed, ".plugin.js" bundled). superseded: supersededFiles(X_TABLE).map(entry => entry.file.replace(/^bt-/, '')), root: ROOT, app: APP, bundledDir: process.env.WAYBETTER_STORE_PLUGINS || join(ROOT, 'apps/desktop/src-tauri/bundled-plugins'), builtinThemes: BUILTIN_THEMES, themeSchemaUrl: THEME_SCHEMA_URL, sanitizeTheme: sanitizeSpec, }); } export default { app: APP, name: 'wayBetter Store', async items() { const { entries, problems } = await source(); if (problems.length) throw new Error(`the Store source has problems (node scripts/check-store.mjs explains each):\n ${problems.join('\n ')}`); return entries; }, };