shell: the panel, createPanel(site) (moved from wayBetter for X)
packages/shell/src/panel (waybetter/shell/panel): an app's own tab. An app describes itself (PanelSite: brand and the home page's words, its own sections and their order, its theme store, catalog and the preview component a theme document is drawn in, Make's examples and docs, the install controller, its languages, what its native side serves) and createPanel returns the component for ShellSite.panel. It is in the shell package because it is drawn in the frame and shares its stores, native bridge and language. - Panel.tsx (header, settings search over every settings section, navigation, toasts; Accounts and Updates), nav.ts (which built-in sections an app gets: each shows only when the app serves what it needs; the app's sections in its order), Home.tsx (hero, highlights, About from the app's data), controls.tsx + panel.css. - Appearance.tsx, ThemeBuilder.tsx + builderModel.ts + builder.css, fonts/ (FontBrowser, FontRoles, catalog, the offline Google Fonts list; scripts/google-fonts-catalog.mjs regenerates it): the theme documents are the runtime's, the store, catalog, accents, draft palette, file suffix and preview are the app's (PanelSite.themes). - Plugins.tsx (the plugins list and custom CSS over the host's plugins_*/custom_css_*), StoreSection.tsx, MakePanel.tsx + makeModel.ts + MarkdownDoc.tsx + markdown.ts + make.css (the examples, the theme file and the docs are the app's), Settings.tsx (links and session over settings_get/set with `siteLinks`, keyword alerts, the media panel), FeatureToggles.tsx (useFeatures + FeatureGroups over features_get/set: the app names its flags and groups), PowerSettings.tsx (deck defaults from site.deck: its flags and presets; DeckPreset gets `name` and `hint`), BackupPanel.tsx + backup.css, DeveloperPanel.tsx, LanguageSettings.tsx, compare.ts. - frame: language.ts (createLanguage: follow the site / the system / one language, i18n_set; moved from the app), appI18n.ts (createAppI18n: the app's typed i18n instance, useT, dates and numbers; the app passes React's useSyncExternalStore), formatDate in i18n.ts (ShellI18n.date). - tests/panel.test.ts: every panel key has English and is used, sections per app, the builder model, the font catalog, plugin header rules, the UI kit demos, Markdown, compare. - npm package: exports ./shell/panel, ./shell/panel/*, ./shell/panel/*.css; the build is scripts/build.mjs (the shell is compiled with the runtime sources it imports under one root and its imports are pointed at dist/runtime; stylesheets and the font list are copied).
This commit is contained in:
parent
81ab5bd9fc
commit
b2767a8e56
44 changed files with 4864 additions and 2 deletions
|
|
@ -3,7 +3,7 @@
|
|||
"version": "0.4.0",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"type": "module",
|
||||
"description": "wayBetter: the framework for apps that run the apps you already use in a light native (Tauri) window and extend them in place. Page runtime (DOM/request hubs, plugins, plugin UI kit with themed dialogs and toasts, theme API and theme JSON Schema, theme color model, link routing, account reporting, deck columns, i18n: ICU-lite messages, locale fallback, plugin strings, catalog checks and JSON Schemas), shell models (address bar, panes, decks, profiles, palette, updates), the shell frame (createShell: tabs, splits, address bar, titlebar, palette, account switcher, decks, workspaces, overlays; React + dockview peers) and the Store: install screen and Store view React components (optional React peer), their state and catalog models, the store catalog JSON Schema and the `waybetter store build|sign|verify` command, `waybetter release windows|macos` (signed native releases and the update manifest, configured by waybetter.release.json) and `waybetter/build` (the page runtime bundle, with an optional esbuild peer). No dependencies.",
|
||||
"description": "wayBetter: the framework for apps that run the apps you already use in a light native (Tauri) window and extend them in place. Page runtime (DOM/request hubs, plugins, plugin UI kit with themed dialogs and toasts, theme API and theme JSON Schema, theme color model, link routing, account reporting, deck columns, i18n: ICU-lite messages, locale fallback, plugin strings, catalog checks and JSON Schemas), shell models (address bar, panes, decks, profiles, palette, updates), the shell frame (createShell: tabs, splits, address bar, titlebar, palette, account switcher, decks, workspaces, overlays, the language state; React + dockview peers), the panel (createPanel: an app's own tab with Appearance and the Theme Builder, plugins and custom CSS, the Store, Make, accounts, settings, backup and sync, developer mode, updates; the app adds its sections) and the Store: install screen and Store view React components (optional React peer), their state and catalog models, the store catalog JSON Schema and the `waybetter store build|sign|verify` command, `waybetter release windows|macos` (signed native releases and the update manifest, configured by waybetter.release.json) and `waybetter/build` (the page runtime bundle, with an optional esbuild peer). No dependencies.",
|
||||
"keywords": [
|
||||
"waybetter",
|
||||
"tauri",
|
||||
|
|
@ -169,6 +169,15 @@
|
|||
"types": "./dist/shell/frame/*.d.ts",
|
||||
"import": "./dist/shell/frame/*.js"
|
||||
},
|
||||
"./shell/panel": {
|
||||
"types": "./dist/shell/panel/index.d.ts",
|
||||
"import": "./dist/shell/panel/index.js"
|
||||
},
|
||||
"./shell/panel/*.css": "./dist/shell/panel/*.css",
|
||||
"./shell/panel/*": {
|
||||
"types": "./dist/shell/panel/*.d.ts",
|
||||
"import": "./dist/shell/panel/*.js"
|
||||
},
|
||||
"./shell/*": {
|
||||
"types": "./dist/shell/*.d.ts",
|
||||
"import": "./dist/shell/*.js"
|
||||
|
|
@ -225,7 +234,7 @@
|
|||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p ../runtime/tsconfig.build.json --outDir dist/runtime --inlineSources --declarationMap false && tsc -p ../shell/tsconfig.build.json --outDir dist/shell --inlineSources --declarationMap false && node -e \"const fs=require('fs');fs.copyFileSync('../shell/src/store.css','dist/shell/store.css');for(const f of fs.readdirSync('../shell/src/frame'))if(f.endsWith('.css'))fs.copyFileSync('../shell/src/frame/'+f,'dist/shell/frame/'+f)\"",
|
||||
"build": "node scripts/build.mjs",
|
||||
"test": "cd ../.. && node --test packages/runtime/tests/*.test.ts packages/shell/tests/*.test.ts packages/waybetter/tests/*.test.mjs",
|
||||
"prepublishOnly": "npm run build && npm test"
|
||||
},
|
||||
|
|
|
|||
50
packages/waybetter/scripts/build.mjs
Normal file
50
packages/waybetter/scripts/build.mjs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// Builds the package's dist/: the page runtime (dist/runtime) and the shell (dist/shell: models,
|
||||
// the Store, the shell frame and the panel) with tsc, then the stylesheets and data files that
|
||||
// travel with the components. Run by `npm run build` (and `prepublishOnly`).
|
||||
//
|
||||
// The shell imports the runtime by source path (`../../../runtime/src/x.ts`), so it is compiled
|
||||
// with both packages under one root and its imports are then pointed at dist/runtime.
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { cpSync, existsSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import { dirname, join, relative } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const packages = join(root, '..');
|
||||
const dist = join(root, 'dist');
|
||||
const tsc = createRequire(import.meta.url).resolve('typescript/bin/tsc');
|
||||
const compile = (...args) => execFileSync(process.execPath, [tsc, ...args, '--inlineSources', '--declarationMap', 'false'], { cwd: root, stdio: 'inherit' });
|
||||
const files = dir => readdirSync(dir).flatMap(name => {
|
||||
const path = join(dir, name);
|
||||
return statSync(path).isDirectory() ? files(path) : [path];
|
||||
});
|
||||
|
||||
rmSync(dist, { recursive: true, force: true });
|
||||
compile('-p', join(packages, 'runtime/tsconfig.build.json'), '--outDir', join(dist, 'runtime'));
|
||||
|
||||
// The shell, with the runtime sources it imports, under one root: <tmp>/shell/src and <tmp>/runtime/src.
|
||||
const tmp = join(dist, '.shell');
|
||||
compile('-p', join(packages, 'shell/tsconfig.build.json'), '--rootDir', packages, '--outDir', tmp);
|
||||
renameSync(join(tmp, 'shell/src'), join(dist, 'shell'));
|
||||
rmSync(tmp, { recursive: true, force: true });
|
||||
// `../../../runtime/src/x.js` (from packages/shell/src/<dir>) is `../../runtime/x.js` in dist/shell/<dir>.
|
||||
let rewritten = 0;
|
||||
for (const file of files(join(dist, 'shell'))) {
|
||||
if (!/\.(js|d\.ts)$/.test(file)) continue;
|
||||
const text = readFileSync(file, 'utf8');
|
||||
const next = text.replace(/((?:\.\.\/)+)runtime\/src\//g, (_, up) => `${up.slice(3)}runtime/`);
|
||||
if (next !== text) { writeFileSync(file, next); rewritten += 1; }
|
||||
}
|
||||
|
||||
// Stylesheets and data files sit next to the components that import them.
|
||||
const source = join(packages, 'shell/src');
|
||||
let copied = 0;
|
||||
for (const file of files(source)) {
|
||||
if (!/\.(css|json)$/.test(file)) continue;
|
||||
const target = join(dist, 'shell', relative(source, file));
|
||||
if (file.endsWith('.json') && existsSync(target)) continue;
|
||||
cpSync(file, target);
|
||||
copied += 1;
|
||||
}
|
||||
console.log(`dist: runtime and shell built (${rewritten} shell files import the runtime, ${copied} stylesheets and data files copied)`);
|
||||
Loading…
Add table
Add a link
Reference in a new issue