@panomc/theme-core 1.0.0-dev.39
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/bin/bundle-internal-libs.js +104 -0
- package/bin/check.js +253 -0
- package/bin/generate-licenses.js +125 -0
- package/bin/generate-runtime-shims.js +180 -0
- package/bin/license/file-fingerprint.js +74 -0
- package/bin/license/finalize-fingerprint.js +72 -0
- package/bin/license/generate-license-constants.js +335 -0
- package/bin/new.js +281 -0
- package/bin/package-zip.js +57 -0
- package/bin/sync.js +326 -0
- package/bin/templates/app.html +59 -0
- package/bin/theme-core.js +103 -0
- package/package.json +77 -0
- package/src/index.js +15 -0
- package/src/kit/hooks-client.js +128 -0
- package/src/kit/hooks-server.js +319 -0
- package/src/kit/license-runtime.js +373 -0
- package/src/kit/resolve.js +71 -0
- package/src/kit/specifiers.js +62 -0
- package/src/kit/svelte-config.js +74 -0
- package/src/kit/vite-config.js +249 -0
- package/src/lib/NotificationManager.js +1 -0
- package/src/lib/PluginAPI.js +368 -0
- package/src/lib/PluginManager.js +1 -0
- package/src/lib/Store.js +43 -0
- package/src/lib/api.util.js +5 -0
- package/src/lib/auth.util.js +77 -0
- package/src/lib/components/App.svelte +10 -0
- package/src/lib/components/Breadcrumb.svelte +88 -0
- package/src/lib/components/CardHeader.svelte +42 -0
- package/src/lib/components/Date.svelte +34 -0
- package/src/lib/components/DefaultToast.svelte +11 -0
- package/src/lib/components/ErrorAlert.svelte +16 -0
- package/src/lib/components/Footer.svelte +223 -0
- package/src/lib/components/Header.svelte +122 -0
- package/src/lib/components/Hook.svelte +71 -0
- package/src/lib/components/LinkCodeInput.svelte +129 -0
- package/src/lib/components/LoginFormBody.svelte +90 -0
- package/src/lib/components/Main.svelte +76 -0
- package/src/lib/components/Navbar.svelte +462 -0
- package/src/lib/components/NoContent.svelte +14 -0
- package/src/lib/components/NotificationContainer.svelte +304 -0
- package/src/lib/components/OnlineAdmins.svelte +64 -0
- package/src/lib/components/PageActions.svelte +39 -0
- package/src/lib/components/PageTitle.svelte +36 -0
- package/src/lib/components/Pagination.svelte +65 -0
- package/src/lib/components/PlayerHead.svelte +58 -0
- package/src/lib/components/PlayerPermissionBadge.svelte +19 -0
- package/src/lib/components/PlayerStatusBadge.svelte +63 -0
- package/src/lib/components/Post.svelte +240 -0
- package/src/lib/components/Posts.svelte +19 -0
- package/src/lib/components/RegisterForm.svelte +125 -0
- package/src/lib/components/Sidebar.svelte +12 -0
- package/src/lib/components/SuccessAlert.svelte +14 -0
- package/src/lib/components/TicketRow.svelte +61 -0
- package/src/lib/components/TicketStatus.svelte +24 -0
- package/src/lib/components/Tickets.svelte +43 -0
- package/src/lib/components/Toast.svelte +13 -0
- package/src/lib/components/ToastContainer.svelte +83 -0
- package/src/lib/components/ViewComponent.svelte +8 -0
- package/src/lib/components/modals/CloseTicketConfirmModal.svelte +121 -0
- package/src/lib/components/modals/ConfirmRemoveAllNotificationsModal.svelte +93 -0
- package/src/lib/components/modals/LogoutSessionConfirmModal.svelte +61 -0
- package/src/lib/components/sidebars/HomeSidebar.svelte +333 -0
- package/src/lib/components/sidebars/PlayerDetailSidebar.svelte +124 -0
- package/src/lib/components/sidebars/ProfileSidebar.svelte +149 -0
- package/src/lib/components/sidebars/SupportSidebar.svelte +54 -0
- package/src/lib/components/sidebars/TicketCreateAndDetailSidebar.svelte +84 -0
- package/src/lib/csrf.js +5 -0
- package/src/lib/init.libs.js +2 -0
- package/src/lib/language.util.js +154 -0
- package/src/lib/layouts/AppLayout.svelte +59 -0
- package/src/lib/layouts/AuthLayout.svelte +29 -0
- package/src/lib/layouts/MainLayout.svelte +60 -0
- package/src/lib/layouts/ProfileLayout.svelte +29 -0
- package/src/lib/layouts/ThemeSettingsLayout.svelte +37 -0
- package/src/lib/layouts/TicketsLayout.svelte +31 -0
- package/src/lib/loginInput.util.js +4 -0
- package/src/lib/orderNavLinks.util.js +58 -0
- package/src/lib/pages/ActivateEmailPage.svelte +48 -0
- package/src/lib/pages/ConfirmNewEmailPage.svelte +48 -0
- package/src/lib/pages/ErrorPage.svelte +41 -0
- package/src/lib/pages/HomePage.svelte +35 -0
- package/src/lib/pages/LoginPage.svelte +448 -0
- package/src/lib/pages/NotificationsPage.svelte +70 -0
- package/src/lib/pages/PlayerDetailPage.svelte +29 -0
- package/src/lib/pages/PostDetailPage.svelte +36 -0
- package/src/lib/pages/PreviewPostPage.svelte +38 -0
- package/src/lib/pages/RegisterPage.svelte +144 -0
- package/src/lib/pages/RenewPasswordPage.svelte +49 -0
- package/src/lib/pages/ResetPasswordPage.svelte +55 -0
- package/src/lib/pages/RulesPage.svelte +52 -0
- package/src/lib/pages/SupportPage.svelte +36 -0
- package/src/lib/pages/ThemeSettingsPage.svelte +551 -0
- package/src/lib/pages/profile/ProfilePage.svelte +32 -0
- package/src/lib/pages/profile/SettingsPage.svelte +163 -0
- package/src/lib/pages/profile/TicketsPage.svelte +54 -0
- package/src/lib/pages/ticket/CreateTicketPage.svelte +48 -0
- package/src/lib/pages/ticket/TicketDetailPage.svelte +59 -0
- package/src/lib/services/auth.js +85 -0
- package/src/lib/services/posts.js +152 -0
- package/src/lib/services/profile.js +37 -0
- package/src/lib/services/theme-setting.js +22 -0
- package/src/lib/services/tickets.js +95 -0
- package/src/lib/siteRealtime.js +244 -0
- package/src/lib/string.util.js +27 -0
- package/src/lib/tooltip.util.js +5 -0
- package/src/lib/ui-logics/layout-logics/AppLayoutLogics.js +321 -0
- package/src/lib/ui-logics/layout-logics/AuthLayoutLogics.js +10 -0
- package/src/lib/ui-logics/layout-logics/MainLayoutLogics.js +19 -0
- package/src/lib/ui-logics/layout-logics/ProfileLayoutLogics.js +10 -0
- package/src/lib/ui-logics/layout-logics/ThemeSettingsLayoutLogics.js +215 -0
- package/src/lib/ui-logics/layout-logics/TicketsLayoutLogics.js +10 -0
- package/src/lib/ui-logics/page-logics/ActiveEmailPageLogics.js +45 -0
- package/src/lib/ui-logics/page-logics/ConfirmNewEmailPageLogics.js +42 -0
- package/src/lib/ui-logics/page-logics/CreateTicketPageLogics.js +83 -0
- package/src/lib/ui-logics/page-logics/HomePageLogics.js +65 -0
- package/src/lib/ui-logics/page-logics/NotificationsPageLogics.js +264 -0
- package/src/lib/ui-logics/page-logics/PlayerDetailPageLogics.js +40 -0
- package/src/lib/ui-logics/page-logics/PostDetailPageLogics.js +58 -0
- package/src/lib/ui-logics/page-logics/PreviewPostPageLogics.js +53 -0
- package/src/lib/ui-logics/page-logics/ProfilePageLogics.js +44 -0
- package/src/lib/ui-logics/page-logics/RenewPasswordPageLogics.js +44 -0
- package/src/lib/ui-logics/page-logics/ResetPasswordPageLogics.js +53 -0
- package/src/lib/ui-logics/page-logics/SettingsPageLogics.js +230 -0
- package/src/lib/ui-logics/page-logics/SupportPageLogics.js +60 -0
- package/src/lib/ui-logics/page-logics/TicketDetailPageLogics.js +160 -0
- package/src/lib/ui-logics/page-logics/TicketsPageLogics.js +132 -0
- package/src/lib/variables.js +1 -0
- package/src/lib/views/ActivateEmailView.svelte +71 -0
- package/src/lib/views/AppLayoutView.svelte +31 -0
- package/src/lib/views/AuthLayoutView.svelte +23 -0
- package/src/lib/views/ConfirmNewEmailView.svelte +71 -0
- package/src/lib/views/CreateTicketView.svelte +73 -0
- package/src/lib/views/ErrorView.svelte +38 -0
- package/src/lib/views/HomeView.svelte +72 -0
- package/src/lib/views/LoginView.svelte +372 -0
- package/src/lib/views/MainLayoutView.svelte +86 -0
- package/src/lib/views/NotificationsView.svelte +129 -0
- package/src/lib/views/PlayerDetailView.svelte +31 -0
- package/src/lib/views/PostDetailView.svelte +199 -0
- package/src/lib/views/PreviewPostView.svelte +151 -0
- package/src/lib/views/ProfileLayoutView.svelte +16 -0
- package/src/lib/views/ProfileView.svelte +68 -0
- package/src/lib/views/RegisterView.svelte +113 -0
- package/src/lib/views/RenewPasswordView.svelte +98 -0
- package/src/lib/views/ResetPasswordView.svelte +88 -0
- package/src/lib/views/RulesView.svelte +26 -0
- package/src/lib/views/SettingsView.svelte +471 -0
- package/src/lib/views/SupportView.svelte +79 -0
- package/src/lib/views/ThemeSettingsLayoutView.svelte +19 -0
- package/src/lib/views/ThemeSettingsView.svelte +1508 -0
- package/src/lib/views/TicketDetailView.svelte +185 -0
- package/src/lib/views/TicketsLayoutView.svelte +21 -0
- package/src/lib/views/TicketsView.svelte +87 -0
- package/src/plugin-engine/engine.js +484 -0
- package/src/registry/index.js +86 -0
- package/src/routes/RootLayout.svelte +21 -0
- package/src/routes/plugin-ui/Layout.svelte +291 -0
- package/src/routes/plugin-ui/Page.svelte +117 -0
- package/src/routes/plugin-ui/layout.js +8 -0
- package/src/routes/plugin-ui/page.js +8 -0
- package/src/routes/plugins-client-file.js +76 -0
- package/src/routes/root-layout-load.js +15 -0
- package/src/routes/theme-api-languages.js +52 -0
- package/src/routes/theme-api-licenses.js +28 -0
package/bin/new.js
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* theme-core new — scaffold a working Pano theme.
|
|
4
|
+
*
|
|
5
|
+
* bunx theme-core new my-theme npm-published core (default)
|
|
6
|
+
* bunx theme-core new my-theme --local file: links into a local theme-core
|
|
7
|
+
* checkout (this workspace)
|
|
8
|
+
*
|
|
9
|
+
* The result runs immediately and looks like vanilla; the author's job starts
|
|
10
|
+
* at src/styles/tokens.scss (Tier 1) and grows through eject-view (Tier 2).
|
|
11
|
+
* vanilla-theme itself is NOT a template: its id is reserved for the SYSTEM
|
|
12
|
+
* theme and it carries repo-specific baggage — this scaffolder is the entry.
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync, copyFileSync } from "node:fs";
|
|
15
|
+
import { join, dirname, resolve } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
import { createRequire } from "node:module";
|
|
18
|
+
|
|
19
|
+
const binDir = dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const corePkgDir = join(binDir, "..");
|
|
21
|
+
const corePkg = JSON.parse(readFileSync(join(corePkgDir, "package.json"), "utf-8"));
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
|
|
24
|
+
const args = process.argv.slice(2);
|
|
25
|
+
const name = args.find((a) => !a.startsWith("-"));
|
|
26
|
+
const local = args.includes("--local") || corePkg.version === "0.0.0-development";
|
|
27
|
+
|
|
28
|
+
if (!name || !/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
29
|
+
console.error("usage: theme-core new <kebab-case-name> [--local]");
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const dir = resolve(process.cwd(), name);
|
|
34
|
+
if (existsSync(dir)) {
|
|
35
|
+
console.error(`[theme-core] ${dir} already exists — refusing to overwrite`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const title = name
|
|
40
|
+
.split("-")
|
|
41
|
+
.map((w) => w[0].toUpperCase() + w.slice(1))
|
|
42
|
+
.join(" ");
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// ---- dependency sources -----------------------------------------------------
|
|
46
|
+
// Local mode links straight into the workspace checkout so the scaffold works
|
|
47
|
+
// before the packages exist on npm; published mode uses semver ranges.
|
|
48
|
+
let coreDep = `^${corePkg.version}`;
|
|
49
|
+
let sdkDep = "*";
|
|
50
|
+
if (local) {
|
|
51
|
+
const sdkDir = dirname(require.resolve("@panomc/sdk/package.json"));
|
|
52
|
+
coreDep = `file:${corePkgDir}`;
|
|
53
|
+
sdkDep = `file:${sdkDir}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ---- token reference --------------------------------------------------------
|
|
57
|
+
// Enumerate every !default variable from the engine SCSS so tokens.scss ships
|
|
58
|
+
// as a commented, self-documenting menu instead of a blank file.
|
|
59
|
+
function collectTokens() {
|
|
60
|
+
const lines = [];
|
|
61
|
+
try {
|
|
62
|
+
const sdkDir = dirname(require.resolve("@panomc/sdk/package.json"));
|
|
63
|
+
for (const [file, label] of [
|
|
64
|
+
["core/scss/custom-bootstrap.scss", "Colors, radius, typography (Bootstrap layer)"],
|
|
65
|
+
["core/scss/themes.scss", "Named dark themes"],
|
|
66
|
+
]) {
|
|
67
|
+
const src = readFileSync(join(sdkDir, file), "utf-8");
|
|
68
|
+
const vars = [...src.matchAll(/^\$([\w-]+)\s*:\s*([^;]*?)\s*!default;/gm)]
|
|
69
|
+
.filter(([, , value]) => !value.includes("\n"));
|
|
70
|
+
if (vars.length) {
|
|
71
|
+
lines.push(`// ── ${label} ${"─".repeat(Math.max(3, 46 - label.length))}`);
|
|
72
|
+
for (const [, varName, value] of vars) lines.push(`// $${varName}: ${value};`);
|
|
73
|
+
lines.push("");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
lines.push(
|
|
78
|
+
"// (token list unavailable at scaffold time — see",
|
|
79
|
+
"// node_modules/@panomc/sdk/core/scss/custom-bootstrap.scss for every variable)",
|
|
80
|
+
"",
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return lines.join("\n");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ---- files ------------------------------------------------------------------
|
|
87
|
+
const FILES = {
|
|
88
|
+
"manifest.json": JSON.stringify(
|
|
89
|
+
{
|
|
90
|
+
id: name,
|
|
91
|
+
title,
|
|
92
|
+
version: "1.0.0",
|
|
93
|
+
author: "CHANGE-ME",
|
|
94
|
+
description: `${title} theme for Pano`,
|
|
95
|
+
panoVersion: "1.0.0",
|
|
96
|
+
screenshots: [],
|
|
97
|
+
premium: false,
|
|
98
|
+
},
|
|
99
|
+
null,
|
|
100
|
+
2,
|
|
101
|
+
) + "\n",
|
|
102
|
+
|
|
103
|
+
"core-meta.json": "{}\n",
|
|
104
|
+
|
|
105
|
+
"theme.config.js": `/**
|
|
106
|
+
* ${title} — thin theme on @panomc/theme-core.
|
|
107
|
+
*
|
|
108
|
+
* Tier 1: edit src/styles/tokens.scss and ship — this file stays empty.
|
|
109
|
+
* Tier 2: eject a view, register it here:
|
|
110
|
+
* bunx theme-core eject-view LoginView
|
|
111
|
+
* Extra settings your views edit are declared in settingsSchema (see the
|
|
112
|
+
* theme-core author guide).
|
|
113
|
+
*/
|
|
114
|
+
export default {
|
|
115
|
+
views: {},
|
|
116
|
+
};
|
|
117
|
+
`,
|
|
118
|
+
|
|
119
|
+
"package.json": JSON.stringify(
|
|
120
|
+
{
|
|
121
|
+
name: `pano-${name}`,
|
|
122
|
+
version: "1.0.0",
|
|
123
|
+
type: "module",
|
|
124
|
+
scripts: {
|
|
125
|
+
dev: "vite dev --host=0.0.0.0 --port 3000",
|
|
126
|
+
"dev:ui": 'concurrently "bun run watch:ui" "bun run dev"',
|
|
127
|
+
"watch:ui":
|
|
128
|
+
"sass src/styles/style.scss static/style.css --watch --load-path=. --load-path=node_modules --quiet-deps --no-source-map",
|
|
129
|
+
"build:ui":
|
|
130
|
+
"sass src/styles/style.scss static/style.css --load-path=. --load-path=node_modules --quiet-deps --no-source-map",
|
|
131
|
+
sync: "bun node_modules/@panomc/theme-core/bin/sync.js",
|
|
132
|
+
check: "bun node_modules/@panomc/theme-core/bin/check.js",
|
|
133
|
+
prebuild:
|
|
134
|
+
"bun node_modules/@panomc/theme-core/bin/generate-runtime-shims.js && node node_modules/@panomc/theme-core/bin/license/generate-license-constants.js",
|
|
135
|
+
build:
|
|
136
|
+
"vite build && node node_modules/@panomc/theme-core/bin/license/finalize-fingerprint.js",
|
|
137
|
+
package: "bun node_modules/@panomc/theme-core/bin/package-zip.js",
|
|
138
|
+
postinstall:
|
|
139
|
+
"bun node_modules/@panomc/theme-core/bin/bundle-internal-libs.js && bun node_modules/@panomc/theme-core/bin/generate-runtime-shims.js",
|
|
140
|
+
},
|
|
141
|
+
devDependencies: {
|
|
142
|
+
"@fortawesome/fontawesome-free": "^6.7.2",
|
|
143
|
+
"@panomc/sdk": sdkDep,
|
|
144
|
+
"animate.css": "^4.1.1",
|
|
145
|
+
"@panomc/theme-core": coreDep,
|
|
146
|
+
"@sveltejs/adapter-node": corePkg.peerDependencies["@sveltejs/adapter-node"],
|
|
147
|
+
"@sveltejs/kit": corePkg.peerDependencies["@sveltejs/kit"],
|
|
148
|
+
"@sveltejs/vite-plugin-svelte": corePkg.peerDependencies["@sveltejs/vite-plugin-svelte"],
|
|
149
|
+
bootstrap: "^5.3.8",
|
|
150
|
+
concurrently: "^9.2.1",
|
|
151
|
+
sass: corePkg.peerDependencies["sass"],
|
|
152
|
+
svelte: corePkg.dependencies.svelte,
|
|
153
|
+
"svelte-i18n": corePkg.peerDependencies["svelte-i18n"],
|
|
154
|
+
"svelte-preprocess": corePkg.peerDependencies["svelte-preprocess"],
|
|
155
|
+
vite: corePkg.peerDependencies["vite"],
|
|
156
|
+
},
|
|
157
|
+
trustedDependencies: ["@parcel/watcher", "es5-ext", "esbuild", "svelte-preprocess"],
|
|
158
|
+
},
|
|
159
|
+
null,
|
|
160
|
+
2,
|
|
161
|
+
) + "\n",
|
|
162
|
+
|
|
163
|
+
"svelte.config.js": `import { createSvelteConfig } from "@panomc/theme-core/kit/svelte-config";
|
|
164
|
+
|
|
165
|
+
export default await createSvelteConfig(import.meta.url);
|
|
166
|
+
`,
|
|
167
|
+
|
|
168
|
+
"vite.config.js": `import { createViteConfig } from "@panomc/theme-core/kit/vite-config";
|
|
169
|
+
|
|
170
|
+
export default createViteConfig();
|
|
171
|
+
`,
|
|
172
|
+
|
|
173
|
+
".env": "VITE_API_URL=http://localhost:8088/api\n",
|
|
174
|
+
|
|
175
|
+
".gitignore": `node_modules/
|
|
176
|
+
build/
|
|
177
|
+
.svelte-kit/
|
|
178
|
+
.claude/
|
|
179
|
+
.idea
|
|
180
|
+
.vscode
|
|
181
|
+
.DS_Store
|
|
182
|
+
|
|
183
|
+
# runtime artifacts — regenerated, never hand-edited
|
|
184
|
+
plugins/
|
|
185
|
+
static/runtime/
|
|
186
|
+
static/lib/
|
|
187
|
+
src/lib/server/license-constants.generated.js
|
|
188
|
+
`,
|
|
189
|
+
|
|
190
|
+
"src/hooks.server.js": `import { createThemeHooks } from "$pano/kit/hooks-server.js";
|
|
191
|
+
import { internalLibsHash } from "$lib/internalLibs.js";
|
|
192
|
+
import { runtimeShimsHash } from "$lib/runtimeShims.js";
|
|
193
|
+
import * as licenseConstants from "$lib/server/license-constants.generated.js";
|
|
194
|
+
|
|
195
|
+
export const { handle, handleError, handleFetch } = createThemeHooks({
|
|
196
|
+
internalLibsHash,
|
|
197
|
+
runtimeShimsHash,
|
|
198
|
+
licenseConstants,
|
|
199
|
+
});
|
|
200
|
+
`,
|
|
201
|
+
|
|
202
|
+
"src/hooks.client.js": `import {
|
|
203
|
+
installRuntimeRegistry,
|
|
204
|
+
createClientInit,
|
|
205
|
+
} from "$pano/kit/hooks-client.js";
|
|
206
|
+
|
|
207
|
+
installRuntimeRegistry();
|
|
208
|
+
|
|
209
|
+
export const init = createClientInit();
|
|
210
|
+
`,
|
|
211
|
+
|
|
212
|
+
"src/styles/tokens.scss": `// Design tokens — imported FIRST by style.scss, so anything you set here
|
|
213
|
+
// overrides the engine's defaults (every variable below is declared !default
|
|
214
|
+
// in the engine).
|
|
215
|
+
//
|
|
216
|
+
// Uncomment a line and change its value; that alone produces a visibly
|
|
217
|
+
// different theme.
|
|
218
|
+
|
|
219
|
+
${collectTokens()}`,
|
|
220
|
+
|
|
221
|
+
"src/styles/style.scss": `// Design tokens first: everything in tokens.scss overrides the engine's
|
|
222
|
+
// !default variables below.
|
|
223
|
+
|
|
224
|
+
@import "tokens";
|
|
225
|
+
|
|
226
|
+
// The engine's stylesheet (Bootstrap + Pano behavior styles), resolved from
|
|
227
|
+
// node_modules via the sass load path.
|
|
228
|
+
|
|
229
|
+
@import "node_modules/@panomc/sdk/core/scss/main";
|
|
230
|
+
@import "node_modules/tippy.js/dist/tippy";
|
|
231
|
+
@import "node_modules/animate.css/animate.min";
|
|
232
|
+
|
|
233
|
+
@import "node_modules/@fortawesome/fontawesome-free/scss/fontawesome";
|
|
234
|
+
@import "node_modules/@fortawesome/fontawesome-free/scss/brands";
|
|
235
|
+
@import "node_modules/@fortawesome/fontawesome-free/scss/solid";
|
|
236
|
+
|
|
237
|
+
// ${title}'s own styles go below.
|
|
238
|
+
`,
|
|
239
|
+
|
|
240
|
+
"src/styles/_empty.scss": "// dev-mode placeholder for the @theme-style alias\n",
|
|
241
|
+
|
|
242
|
+
"lang-overrides/.gitkeep": "",
|
|
243
|
+
"screenshots/.gitkeep": "",
|
|
244
|
+
|
|
245
|
+
"README.md": `# ${title}
|
|
246
|
+
|
|
247
|
+
A Pano theme built on [@panomc/theme-core](https://github.com/PanoMC/sdk).
|
|
248
|
+
|
|
249
|
+
\`\`\`sh
|
|
250
|
+
bun install
|
|
251
|
+
bun run sync # generate routes / lang / lib bridges
|
|
252
|
+
bun run dev # against a local Pano backend (VITE_API_URL in .env)
|
|
253
|
+
bun run check # contract lint
|
|
254
|
+
bun run build && bun run package
|
|
255
|
+
\`\`\`
|
|
256
|
+
|
|
257
|
+
- Tier 1: edit \`src/styles/tokens.scss\`.
|
|
258
|
+
- Tier 2: \`bunx theme-core eject-view <ViewName>\` (see \`theme-core list-views\`).
|
|
259
|
+
`,
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
for (const [rel, content] of Object.entries(FILES)) {
|
|
264
|
+
const target = join(dir, rel);
|
|
265
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
266
|
+
writeFileSync(target, content);
|
|
267
|
+
}
|
|
268
|
+
copyFileSync(join(binDir, "templates", "app.html"), join(dir, "src", "app.html"));
|
|
269
|
+
|
|
270
|
+
console.log(`[theme-core] scaffolded ${name}/ (${Object.keys(FILES).length + 1} files, ${local ? "local workspace links" : `core ^${corePkg.version}`})
|
|
271
|
+
|
|
272
|
+
Next steps:
|
|
273
|
+
cd ${name}
|
|
274
|
+
bun install # if it hangs at "Resolving": bun install --backend=copyfile
|
|
275
|
+
bun run sync # generates src/routes, src/lib bridges, lang/
|
|
276
|
+
bun run dev # needs a Pano backend (VITE_API_URL in .env)
|
|
277
|
+
|
|
278
|
+
Make it yours:
|
|
279
|
+
src/styles/tokens.scss colors / fonts / radius (Tier 1)
|
|
280
|
+
bunx theme-core list-views what you can override
|
|
281
|
+
bunx theme-core eject-view HomeView own a page's markup (Tier 2)`);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* theme-core package — deterministic zip of build/.
|
|
4
|
+
*
|
|
5
|
+
* The whole-zip sha256 IS the premium license identity on panomc.com, and
|
|
6
|
+
* bot-driven rebuilds must not churn license claims — so the zip must be
|
|
7
|
+
* byte-reproducible: fixed mtimes, stable entry order, no extra fields.
|
|
8
|
+
* (The build itself is reproducible because the core svelte-config factory
|
|
9
|
+
* pins kit.version.name; see docs/P0-SPIKE.md.)
|
|
10
|
+
*
|
|
11
|
+
* Usage: theme-core package [outfile.zip] (default: <id>-<version>.zip)
|
|
12
|
+
*/
|
|
13
|
+
import { execFileSync } from "node:child_process";
|
|
14
|
+
import { existsSync, readFileSync, rmSync, utimesSync, readdirSync, statSync } from "node:fs";
|
|
15
|
+
import { join, resolve } from "node:path";
|
|
16
|
+
|
|
17
|
+
const ROOT = process.cwd();
|
|
18
|
+
|
|
19
|
+
const BUILD = join(ROOT, "build");
|
|
20
|
+
|
|
21
|
+
if (!existsSync(join(BUILD, "manifest.json"))) {
|
|
22
|
+
console.error("[theme-core] build/manifest.json missing — run `bun run build` first");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const manifest = JSON.parse(readFileSync(join(BUILD, "manifest.json"), "utf-8"));
|
|
27
|
+
const out = resolve(ROOT, process.argv[2] ?? `${manifest.id}-${manifest.version}.zip`);
|
|
28
|
+
|
|
29
|
+
// Fixed mtime: any constant works; changing it changes every future zip hash,
|
|
30
|
+
// so treat it as frozen.
|
|
31
|
+
const EPOCH = new Date("2026-01-01T00:00:00Z");
|
|
32
|
+
// Safety: never let repo internals or a previous zip leak into the artifact.
|
|
33
|
+
const EXCLUDE = new Set([".git", ".gitignore", ".claude", "node_modules", ".DS_Store"]);
|
|
34
|
+
|
|
35
|
+
const files = [];
|
|
36
|
+
(function walk(dir) {
|
|
37
|
+
for (const entry of readdirSync(dir).sort()) {
|
|
38
|
+
if (EXCLUDE.has(entry) || entry.endsWith(".zip")) continue;
|
|
39
|
+
const p = join(dir, entry);
|
|
40
|
+
if (statSync(p).isDirectory()) walk(p);
|
|
41
|
+
else {
|
|
42
|
+
utimesSync(p, EPOCH, EPOCH);
|
|
43
|
+
files.push(p.slice(BUILD.length + 1));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})(BUILD);
|
|
47
|
+
|
|
48
|
+
if (existsSync(out)) rmSync(out);
|
|
49
|
+
execFileSync("zip", ["-X", "-q", out, "-@"], {
|
|
50
|
+
cwd: BUILD,
|
|
51
|
+
input: files.join("\n"),
|
|
52
|
+
env: { ...process.env, TZ: "UTC" },
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const hash = execFileSync("sha256sum", [out]).toString().split(" ")[0];
|
|
56
|
+
console.log(`[theme-core] ${out}`);
|
|
57
|
+
console.log(`[theme-core] ${files.length} entries, sha256 ${hash} (this hash is the premium license identity)`);
|
package/bin/sync.js
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* theme-core sync — (re)generates the theme's src/routes shim tree.
|
|
4
|
+
*
|
|
5
|
+
* Every route file in a theme is a one-line delegation into @panomc/theme-core
|
|
6
|
+
* (via the $pano vite alias). This script owns that tree: on a core upgrade a
|
|
7
|
+
* new route materializes as a new shim file, a removed one disappears, and the
|
|
8
|
+
* theme author never edits src/routes by hand.
|
|
9
|
+
*
|
|
10
|
+
* Ejecting: put the marker @theme-core-eject anywhere in a generated file
|
|
11
|
+
* (JS comment or HTML comment) and sync will never touch that file again —
|
|
12
|
+
* the author owns it from that point on.
|
|
13
|
+
*
|
|
14
|
+
* Run from the THEME's root: bun node_modules/@panomc/theme-core/bin/sync.js
|
|
15
|
+
*/
|
|
16
|
+
import { mkdirSync, writeFileSync, readFileSync, existsSync, readdirSync, statSync, rmSync } from "node:fs";
|
|
17
|
+
import { join, dirname } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
|
|
20
|
+
const EJECT_MARKER = "@theme-core-eject";
|
|
21
|
+
const HEADER_JS = "// AUTO-GENERATED by theme-core sync — do not edit.\n// To take ownership of this file, add an eject comment (see theme-core docs).\n";
|
|
22
|
+
const HEADER_SVELTE = "<!-- AUTO-GENERATED by theme-core sync — do not edit. To take ownership, add an eject comment (see theme-core docs). -->\n";
|
|
23
|
+
|
|
24
|
+
const reexport = (what, from) => `${HEADER_JS}export { ${what} } from "${from}";\n`;
|
|
25
|
+
|
|
26
|
+
const renderPage = (name, from, props = "{data}") =>
|
|
27
|
+
`${HEADER_SVELTE}<script>
|
|
28
|
+
import ${name} from "${from}";
|
|
29
|
+
|
|
30
|
+
export let data;
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<${name} ${props === "none" ? "" : props === "{data}" ? "{data}" : props}/>
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const wrapLayout = (name, from) =>
|
|
37
|
+
`${HEADER_SVELTE}<script>
|
|
38
|
+
import ${name} from "${from}";
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<${name}><slot /></${name}>
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
const pagePair = (route, component, pagePath, props = "{data}") => [
|
|
45
|
+
{
|
|
46
|
+
path: `${route}/+page.js`,
|
|
47
|
+
content: reexport("load", `$pano/lib/pages/${pagePath}`),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
path: `${route}/+page.svelte`,
|
|
51
|
+
content: renderPage(component, `$pano/lib/pages/${pagePath}`, props),
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const layoutPair = (route, component, layoutPath) => [
|
|
56
|
+
{
|
|
57
|
+
path: `${route}/+layout.js`,
|
|
58
|
+
content: reexport("load", `$pano/lib/layouts/${layoutPath}`),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
path: `${route}/+layout.svelte`,
|
|
62
|
+
content: wrapLayout(component, `$pano/lib/layouts/${layoutPath}`),
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/** The canonical Pano theme route tree. Grouping names are part of the theme
|
|
67
|
+
* contract: RootLayout keys off "(theme-settings)" to suppress MainLayout. */
|
|
68
|
+
const FILES = [
|
|
69
|
+
// ---- root
|
|
70
|
+
{
|
|
71
|
+
path: "+layout.js",
|
|
72
|
+
content: `${HEADER_JS}import themeConfig from "../../theme.config.js";
|
|
73
|
+
import { setThemeConfig } from "$pano/registry/index.js";
|
|
74
|
+
|
|
75
|
+
// Module side effect: the registry is populated on server and client before
|
|
76
|
+
// any load function runs.
|
|
77
|
+
setThemeConfig(themeConfig);
|
|
78
|
+
|
|
79
|
+
export { load } from "$pano/routes/root-layout-load.js";
|
|
80
|
+
`,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
path: "+layout.svelte",
|
|
84
|
+
content: `${HEADER_SVELTE}<script>
|
|
85
|
+
import RootLayout from "$pano/routes/RootLayout.svelte";
|
|
86
|
+
|
|
87
|
+
export let data;
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<RootLayout {data}><slot /></RootLayout>
|
|
91
|
+
`,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
path: "+layout.server.js",
|
|
95
|
+
content: reexport("loadServer as load", "$pano/lib/layouts/AppLayout.svelte"),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
path: "+error.svelte",
|
|
99
|
+
content: `${HEADER_SVELTE}<script>
|
|
100
|
+
import Error from "$pano/lib/pages/ErrorPage.svelte";
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<Error />
|
|
104
|
+
`,
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
// ---- (plugin-ui) catch-all host
|
|
108
|
+
{
|
|
109
|
+
path: "(plugin-ui)/[...path]/+layout.js",
|
|
110
|
+
content: reexport("load", "$pano/routes/plugin-ui/layout.js"),
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
path: "(plugin-ui)/[...path]/+layout.svelte",
|
|
114
|
+
content: `${HEADER_SVELTE}<script>
|
|
115
|
+
import Layout from "$pano/routes/plugin-ui/Layout.svelte";
|
|
116
|
+
|
|
117
|
+
export let data;
|
|
118
|
+
</script>
|
|
119
|
+
|
|
120
|
+
<Layout {data}><slot /></Layout>
|
|
121
|
+
`,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
path: "(plugin-ui)/[...path]/+page.js",
|
|
125
|
+
content: reexport("load", "$pano/routes/plugin-ui/page.js"),
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
path: "(plugin-ui)/[...path]/+page.svelte",
|
|
129
|
+
content: `${HEADER_SVELTE}<script>
|
|
130
|
+
import Page from "$pano/routes/plugin-ui/Page.svelte";
|
|
131
|
+
|
|
132
|
+
export let data;
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<Page {data} />
|
|
136
|
+
`,
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// ---- (theme) group
|
|
140
|
+
{ path: "(theme)/+layout.js", content: `${HEADER_JS}` },
|
|
141
|
+
{ path: "(theme)/+layout.svelte", content: `${HEADER_SVELTE}<slot />\n` },
|
|
142
|
+
...pagePair("(theme)", "Home", "HomePage.svelte"),
|
|
143
|
+
...pagePair("(theme)/activate", "ActivateEmailPage", "ActivateEmailPage.svelte"),
|
|
144
|
+
...pagePair("(theme)/activate-new-email", "ConfirmNewEmailPage", "ConfirmNewEmailPage.svelte"),
|
|
145
|
+
...layoutPair("(theme)/login", "AuthLayout", "AuthLayout.svelte"),
|
|
146
|
+
...pagePair("(theme)/login", "LoginPage", "LoginPage.svelte"),
|
|
147
|
+
...pagePair("(theme)/notifications", "NotificationsPage", "NotificationsPage.svelte"),
|
|
148
|
+
...pagePair("(theme)/player/[player]", "PlayerDetailPage", "PlayerDetailPage.svelte"),
|
|
149
|
+
...pagePair("(theme)/post/[url]", "PostDetailPage", "PostDetailPage.svelte"),
|
|
150
|
+
...pagePair("(theme)/preview/post/[id]", "PreviewPostPage", "PreviewPostPage.svelte", 'post="{data.post}"'),
|
|
151
|
+
...layoutPair("(theme)/profile", "ProfileLayout", "ProfileLayout.svelte"),
|
|
152
|
+
...pagePair("(theme)/profile", "ProfilePage", "profile/ProfilePage.svelte"),
|
|
153
|
+
...pagePair("(theme)/profile/settings", "SettingsPage", "profile/SettingsPage.svelte"),
|
|
154
|
+
...layoutPair("(theme)/register", "AuthLayout", "AuthLayout.svelte"),
|
|
155
|
+
...pagePair("(theme)/register", "RegisterPage", "RegisterPage.svelte"),
|
|
156
|
+
...pagePair("(theme)/renew-password", "RenewPasswordPage", "RenewPasswordPage.svelte"),
|
|
157
|
+
...layoutPair("(theme)/reset-password", "AuthLayout", "AuthLayout.svelte"),
|
|
158
|
+
...pagePair("(theme)/reset-password", "ResetPasswordPage", "ResetPasswordPage.svelte", "none"),
|
|
159
|
+
...pagePair("(theme)/rules", "RulesPage", "RulesPage.svelte"),
|
|
160
|
+
...pagePair("(theme)/support", "SupportPage", "SupportPage.svelte"),
|
|
161
|
+
...layoutPair("(theme)/ticket", "TicketsLayout", "TicketsLayout.svelte"),
|
|
162
|
+
...pagePair("(theme)/ticket/[id]", "TicketDetailPage", "ticket/TicketDetailPage.svelte"),
|
|
163
|
+
...pagePair("(theme)/ticket/create", "CreateTicketPage", "ticket/CreateTicketPage.svelte"),
|
|
164
|
+
...layoutPair("(theme)/tickets", "TicketsLayout", "TicketsLayout.svelte"),
|
|
165
|
+
...pagePair("(theme)/tickets", "TicketsPage", "profile/TicketsPage.svelte"),
|
|
166
|
+
{
|
|
167
|
+
path: "(theme)/plugins/[pluginId]/resources/plugin-ui/client/[fileName]/+server.js",
|
|
168
|
+
content: reexport("GET", "$pano/routes/plugins-client-file.js"),
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
path: "(theme)/theme-api/languages/[language].json/+server.js",
|
|
172
|
+
content: reexport("GET", "$pano/routes/theme-api-languages.js"),
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
path: "(theme)/theme-api/licenses.json/+server.js",
|
|
176
|
+
content: reexport("GET", "$pano/routes/theme-api-licenses.js"),
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
// ---- (theme-settings) group (name is contractual — see RootLayout)
|
|
180
|
+
{
|
|
181
|
+
path: "(theme-settings)/theme-settings/+layout.js",
|
|
182
|
+
content: reexport("load", "$pano/lib/layouts/ThemeSettingsLayout.svelte"),
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
path: "(theme-settings)/theme-settings/+layout.server.js",
|
|
186
|
+
content: reexport("loadServer as load", "$pano/lib/layouts/ThemeSettingsLayout.svelte"),
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
path: "(theme-settings)/theme-settings/+layout.svelte",
|
|
190
|
+
content: wrapLayout("ThemeSettingsLayout", "$pano/lib/layouts/ThemeSettingsLayout.svelte"),
|
|
191
|
+
},
|
|
192
|
+
...pagePair("(theme-settings)/theme-settings", "ThemeSettingsPage", "ThemeSettingsPage.svelte"),
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Host-provides stubs: @panomc/sdk's core/js modules import a handful of
|
|
197
|
+
* modules from "$lib/..." by contract — the HOST app must supply them. In a
|
|
198
|
+
* thin theme they are one-line re-exports into the core engine.
|
|
199
|
+
*/
|
|
200
|
+
const LIB_STUBS = [
|
|
201
|
+
{
|
|
202
|
+
path: "variables.js",
|
|
203
|
+
content: `${HEADER_JS}export * from "$pano/lib/variables.js";\n`,
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
path: "Store.js",
|
|
207
|
+
content: `${HEADER_JS}export * from "$pano/lib/Store.js";\n`,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
path: "api.util.js",
|
|
211
|
+
content: `${HEADER_JS}export * from "$pano/lib/api.util.js";\nexport { default } from "$pano/lib/api.util.js";\n`,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
path: "PluginAPI.js",
|
|
215
|
+
content: `${HEADER_JS}export * from "$pano/lib/PluginAPI.js";\n`,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
path: "components/ToastContainer.svelte",
|
|
219
|
+
content: `${HEADER_SVELTE}<script context="module">
|
|
220
|
+
export { show } from "$pano/lib/components/ToastContainer.svelte";
|
|
221
|
+
</script>
|
|
222
|
+
|
|
223
|
+
<script>
|
|
224
|
+
import ToastContainer from "$pano/lib/components/ToastContainer.svelte";
|
|
225
|
+
</script>
|
|
226
|
+
|
|
227
|
+
<ToastContainer />
|
|
228
|
+
`,
|
|
229
|
+
},
|
|
230
|
+
];
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* lang/ is GENERATED: core ships the base translation trees (new i18n keys
|
|
234
|
+
* arrive with a core bump instead of rendering as raw keys); a theme adds or
|
|
235
|
+
* replaces keys via lang-overrides/<locale>.json. Deep merge, additive only —
|
|
236
|
+
* an overlay cannot delete a base key, so core additions always surface.
|
|
237
|
+
*/
|
|
238
|
+
function deepMerge(base, overlay) {
|
|
239
|
+
const out = { ...base };
|
|
240
|
+
for (const [k, v] of Object.entries(overlay)) {
|
|
241
|
+
out[k] =
|
|
242
|
+
v && typeof v === "object" && !Array.isArray(v) && typeof out[k] === "object"
|
|
243
|
+
? deepMerge(out[k] ?? {}, v)
|
|
244
|
+
: v;
|
|
245
|
+
}
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function syncLang() {
|
|
250
|
+
const coreLangDir = join(dirname(fileURLToPath(import.meta.url)), "..", "lang");
|
|
251
|
+
const overrideDir = join(process.cwd(), "lang-overrides");
|
|
252
|
+
const outDir = join(process.cwd(), "lang");
|
|
253
|
+
mkdirSync(outDir, { recursive: true });
|
|
254
|
+
|
|
255
|
+
let merged = 0;
|
|
256
|
+
for (const file of readdirSync(coreLangDir)) {
|
|
257
|
+
if (!file.endsWith(".json")) continue;
|
|
258
|
+
const base = JSON.parse(readFileSync(join(coreLangDir, file), "utf-8"));
|
|
259
|
+
const overridePath = join(overrideDir, file);
|
|
260
|
+
const overlay = existsSync(overridePath)
|
|
261
|
+
? JSON.parse(readFileSync(overridePath, "utf-8"))
|
|
262
|
+
: {};
|
|
263
|
+
writeFileSync(
|
|
264
|
+
join(outDir, file),
|
|
265
|
+
JSON.stringify(deepMerge(base, overlay), null, 2) + "\n",
|
|
266
|
+
);
|
|
267
|
+
merged++;
|
|
268
|
+
}
|
|
269
|
+
return merged;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const routesDir = join(process.cwd(), "src", "routes");
|
|
273
|
+
let written = 0;
|
|
274
|
+
let ejected = 0;
|
|
275
|
+
|
|
276
|
+
const known = new Set(FILES.map((f) => join(routesDir, f.path)));
|
|
277
|
+
|
|
278
|
+
const libDir = join(process.cwd(), "src", "lib");
|
|
279
|
+
|
|
280
|
+
for (const [baseDir, files] of [
|
|
281
|
+
[routesDir, FILES],
|
|
282
|
+
[libDir, LIB_STUBS],
|
|
283
|
+
]) {
|
|
284
|
+
for (const file of files) {
|
|
285
|
+
const target = join(baseDir, file.path);
|
|
286
|
+
|
|
287
|
+
if (
|
|
288
|
+
existsSync(target) &&
|
|
289
|
+
readFileSync(target, "utf-8").includes(EJECT_MARKER)
|
|
290
|
+
) {
|
|
291
|
+
ejected++;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
296
|
+
writeFileSync(target, file.content);
|
|
297
|
+
written++;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Remove stale generated files (routes that no longer exist in core). Ejected
|
|
302
|
+
// and theme-invented files are left alone.
|
|
303
|
+
let removed = 0;
|
|
304
|
+
function sweep(dir) {
|
|
305
|
+
if (!existsSync(dir)) return;
|
|
306
|
+
for (const entry of readdirSync(dir)) {
|
|
307
|
+
const p = join(dir, entry);
|
|
308
|
+
if (statSync(p).isDirectory()) {
|
|
309
|
+
sweep(p);
|
|
310
|
+
if (readdirSync(p).length === 0) rmSync(p, { recursive: true });
|
|
311
|
+
} else if (!known.has(p)) {
|
|
312
|
+
const body = readFileSync(p, "utf-8");
|
|
313
|
+
if (body.includes("AUTO-GENERATED by theme-core sync") && !body.includes(EJECT_MARKER)) {
|
|
314
|
+
rmSync(p);
|
|
315
|
+
removed++;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
sweep(routesDir);
|
|
321
|
+
|
|
322
|
+
const langMerged = syncLang();
|
|
323
|
+
|
|
324
|
+
console.log(
|
|
325
|
+
`theme-core sync: ${written} shims written, ${ejected} ejected (kept), ${removed} stale removed, ${langMerged} lang files merged`,
|
|
326
|
+
);
|