@panomc/theme-core 1.0.0-dev.64 → 1.0.0-dev.65
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/__tests__/cli/core-meta.test.js +6 -7
- package/bin/new.js +0 -5
- package/bin/package-zip.js +2 -2
- package/bin/sync.js +3 -3
- package/package.json +19 -19
- package/src/kit/__tests__/hooks-server-fetch.test.js +1 -1
- package/src/kit/hooks-client.js +1 -1
- package/src/kit/hooks-server.js +1 -1
- package/src/kit/resolve.js +1 -1
- package/src/kit/svelte-config.js +37 -30
- package/src/kit/vite-config.js +31 -9
- package/src/lib/PluginAPI.js +19 -2
- package/src/lib/__tests__/controllerHost.test.js +2 -2
- package/src/lib/__tests__/cx03.test.js +2 -2
- package/src/lib/__tests__/engineBoot.test.js +1 -1
- package/src/lib/__tests__/engineParts.helper.js +2 -1
- package/src/lib/__tests__/engineParts.test.js +1 -1
- package/src/lib/__tests__/engineSidebars.helper.js +3 -3
- package/src/lib/__tests__/engineSidebars.test.js +1 -1
- package/src/lib/__tests__/engineWiring.test.js +8 -8
- package/src/lib/__tests__/fallbackStyles.test.js +5 -5
- package/src/lib/__tests__/home.test.js +1 -1
- package/src/lib/__tests__/injectedScope.test.js +2 -2
- package/src/lib/__tests__/languageConcurrency.test.js +1 -1
- package/src/lib/__tests__/languageLayers.test.js +1 -1
- package/src/lib/__tests__/pluginApiViews.test.js +2 -2
- package/src/lib/__tests__/registryReady.test.js +1 -1
- package/src/lib/__tests__/returnTo.util.test.js +8 -5
- package/src/lib/__tests__/routeConfig.test.js +1 -1
- package/src/lib/__tests__/skinContract.test.js +1 -1
- package/src/lib/__tests__/tc03.test.js +8 -5
- package/src/lib/__tests__/tc11.test.js +1 -1
- package/src/lib/auth.util.js +2 -2
- package/src/lib/components/App.svelte +1 -1
- package/src/lib/components/FallbackLinks.svelte +1 -1
- package/src/lib/components/Hook.svelte +1 -1
- package/src/lib/components/Main.svelte +1 -1
- package/src/lib/components/Navbar.svelte +2 -2
- package/src/lib/components/NotificationContainer.svelte +3 -3
- package/src/lib/components/PluginBlock.svelte +2 -2
- package/src/lib/components/sidebars/ProfileSidebar.svelte +2 -2
- package/src/lib/controllerHost.js +2 -2
- package/src/lib/language.util.js +2 -2
- package/src/lib/layouts/AppLayout.svelte +1 -1
- package/src/lib/layouts/AuthLayout.svelte +1 -1
- package/src/lib/layouts/MainLayout.svelte +1 -1
- package/src/lib/layouts/ProfileLayout.svelte +1 -1
- package/src/lib/layouts/ThemeSettingsLayout.svelte +1 -1
- package/src/lib/layouts/TicketsLayout.svelte +1 -1
- package/src/lib/pages/LoginPage.svelte +1 -1
- package/src/lib/pages/PreviewPostPage.svelte +1 -1
- package/src/lib/pages/RegisterPage.svelte +1 -1
- package/src/lib/pages/ResetPasswordPage.svelte +1 -1
- package/src/lib/siteRealtime.js +1 -1
- package/src/lib/ui-logics/layout-logics/AppLayoutLogics.js +8 -5
- package/src/lib/ui-logics/layout-logics/ThemeSettingsLayoutLogics.js +1 -1
- package/src/lib/ui-logics/page-logics/NotificationsPageLogics.js +1 -1
- package/src/lib/ui-logics/page-logics/TicketsPageLogics.js +1 -1
- package/src/lib/views/NotificationsView.svelte +1 -1
- package/src/plugin-engine/engine.js +2 -2
- package/src/registry/__tests__/registry.test.js +1 -1
- package/src/registry/__tests__/view.test.js +1 -1
- package/src/registry/index.js +1 -1
- package/src/routes/RootLayout.svelte +2 -2
- package/src/routes/catalogue/__tests__/catalogue.test.js +3 -3
- package/src/routes/catalogue/deps.js +2 -2
- package/src/routes/plugin-ui/Layout.svelte +2 -2
- package/src/routes/plugin-ui/Page.svelte +1 -1
|
@@ -202,7 +202,7 @@ describe("build plugins of the vite config", () => {
|
|
|
202
202
|
async function runPlugin(plugin, themeDir) {
|
|
203
203
|
process.chdir(themeDir);
|
|
204
204
|
plugin.configResolved?.();
|
|
205
|
-
await plugin.
|
|
205
|
+
await plugin.buildApp.handler();
|
|
206
206
|
process.chdir(cwd);
|
|
207
207
|
}
|
|
208
208
|
|
|
@@ -272,7 +272,7 @@ describe("build plugins of the vite config", () => {
|
|
|
272
272
|
});
|
|
273
273
|
});
|
|
274
274
|
|
|
275
|
-
describe("
|
|
275
|
+
describe("kit options", () => {
|
|
276
276
|
test("adds the $contracts alias and keeps the author's aliases", () => {
|
|
277
277
|
// the factory imports its toolchain from the theme: two stubs stand in for it
|
|
278
278
|
const theme = makeTheme({
|
|
@@ -283,15 +283,14 @@ describe("svelte config", () => {
|
|
|
283
283
|
"node_modules/@sveltejs/adapter-node/index.js": "export default () => ({ name: 'stub' });\n",
|
|
284
284
|
},
|
|
285
285
|
});
|
|
286
|
-
const url = "file://" + join(theme, "svelte.config.js");
|
|
287
286
|
const spawn = spawnSync(
|
|
288
287
|
"bun",
|
|
289
288
|
[
|
|
290
289
|
"-e",
|
|
291
|
-
`const {
|
|
292
|
-
const a = await
|
|
293
|
-
const b = await
|
|
294
|
-
console.log(JSON.stringify([a.
|
|
290
|
+
`const { createKitOptions } = await import(${JSON.stringify(join(binDir, "..", "src", "kit", "svelte-config.js"))});
|
|
291
|
+
const a = await createKitOptions(${JSON.stringify(theme)});
|
|
292
|
+
const b = await createKitOptions(${JSON.stringify(theme)}, { alias: { $x: "src/x" } });
|
|
293
|
+
console.log(JSON.stringify([a.alias, b.alias]));`,
|
|
295
294
|
],
|
|
296
295
|
{ cwd: theme, encoding: "utf8" },
|
|
297
296
|
);
|
package/bin/new.js
CHANGED
|
@@ -292,11 +292,6 @@ export default {
|
|
|
292
292
|
2,
|
|
293
293
|
) + "\n",
|
|
294
294
|
|
|
295
|
-
"svelte.config.js": `import { createSvelteConfig } from "@panomc/theme-core/kit/svelte-config";
|
|
296
|
-
|
|
297
|
-
export default await createSvelteConfig(import.meta.url);
|
|
298
|
-
`,
|
|
299
|
-
|
|
300
295
|
"vite.config.js": `import { createViteConfig } from "@panomc/theme-core/kit/vite-config";
|
|
301
296
|
|
|
302
297
|
export default createViteConfig();
|
package/bin/package-zip.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* The whole-zip sha256 IS the premium license identity on panomc.com, and
|
|
6
6
|
* bot-driven rebuilds must not churn license claims — so the zip must be
|
|
7
7
|
* byte-reproducible: fixed mtimes, stable entry order, no extra fields.
|
|
8
|
-
* (The build itself is reproducible because the core svelte-config
|
|
9
|
-
*
|
|
8
|
+
* (The build itself is reproducible because the core kit options (kit/svelte-config.js)
|
|
9
|
+
* pin version.name; see docs/P0-SPIKE.md.)
|
|
10
10
|
*
|
|
11
11
|
* `check.js --strict` runs first and a failure stops the packaging, so every published theme passes the
|
|
12
12
|
* same contract check.
|
package/bin/sync.js
CHANGED
|
@@ -90,11 +90,11 @@ const layoutPair = (route, component, layoutPath) => [
|
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* The view catalogue routes (doc 02 section 7): theme dev mode only. A generated file never imports catalogue
|
|
93
|
-
* code statically: `dev` from `$app/
|
|
93
|
+
* code statically: `dev` from `$app/env` is a build-time constant, so a production build drops the
|
|
94
94
|
* dynamic import and its chunk, and the routes answer 404. (`ssr` is on in a production build so that the 404
|
|
95
95
|
* is a real status and not an empty shell; in dev the catalogue renders in the browser only.)
|
|
96
96
|
*/
|
|
97
|
-
const catalogueLoad = (module, run) => `${HEADER_JS}import { dev } from "$app/
|
|
97
|
+
const catalogueLoad = (module, run) => `${HEADER_JS}import { dev } from "$app/env";
|
|
98
98
|
import { error } from "@sveltejs/kit";
|
|
99
99
|
|
|
100
100
|
export const ssr = !dev;
|
|
@@ -117,7 +117,7 @@ const cataloguePage = `${HEADER_SVELTE}<script>
|
|
|
117
117
|
const catalogueServer = () => {
|
|
118
118
|
const hasConfig = existsSync(join(process.cwd(), "theme.config.js"));
|
|
119
119
|
|
|
120
|
-
return `${HEADER_JS}import { dev } from "$app/
|
|
120
|
+
return `${HEADER_JS}import { dev } from "$app/env";
|
|
121
121
|
import { error } from "@sveltejs/kit";
|
|
122
122
|
${hasConfig ? `import themeConfig from "../../../../../theme.config.js";\nimport { setThemeConfig } from "$pano/registry/index.js";\n\nsetThemeConfig(themeConfig);\n` : ""}
|
|
123
123
|
export const GET = async (event) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panomc/theme-core",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.65",
|
|
4
4
|
"description": "The Pano theme engine: hooks factories, plugin engine, headless page controllers, default views and the theme CLI. Themes depend on this package instead of forking vanilla-theme.",
|
|
5
5
|
"author": "PanoMC",
|
|
6
6
|
"pano": {
|
|
@@ -51,34 +51,34 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@clack/prompts": "^
|
|
54
|
+
"@clack/prompts": "^1.8.1",
|
|
55
55
|
"picocolors": "^1.1.0",
|
|
56
|
-
"svelte": "5.
|
|
56
|
+
"svelte": "5.57.2",
|
|
57
57
|
"mime-types": "^3.0.2",
|
|
58
|
-
"date-fns": "^4.
|
|
59
|
-
"copy-to-clipboard": "^
|
|
58
|
+
"date-fns": "^4.4.0",
|
|
59
|
+
"copy-to-clipboard": "^4.0.2",
|
|
60
60
|
"@jill64/universal-sanitizer": "^1.4.6",
|
|
61
61
|
"@fortawesome/fontawesome-free": "^6.7.2"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@panomc/sdk": "^2.0.0-dev.
|
|
65
|
-
"@sveltejs/adapter-node": "^
|
|
66
|
-
"@sveltejs/kit": "^
|
|
67
|
-
"@sveltejs/vite-plugin-svelte": "^7.
|
|
68
|
-
"sass": "^1.
|
|
64
|
+
"@panomc/sdk": "^2.0.0-dev.65",
|
|
65
|
+
"@sveltejs/adapter-node": "^6.0.0",
|
|
66
|
+
"@sveltejs/kit": "^3.1.0",
|
|
67
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
68
|
+
"sass": "^1.105.1",
|
|
69
69
|
"svelte-i18n": "^4.0.1",
|
|
70
|
-
"svelte-preprocess": "^6.0.
|
|
71
|
-
"vite": "^8.
|
|
70
|
+
"svelte-preprocess": "^6.0.5",
|
|
71
|
+
"vite": "^8.3.4"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@panomc/sdk": "2.0.0-dev.
|
|
75
|
-
"@sveltejs/adapter-node": "^
|
|
76
|
-
"@sveltejs/kit": "^
|
|
77
|
-
"@sveltejs/vite-plugin-svelte": "^7.
|
|
78
|
-
"sass": "^1.
|
|
74
|
+
"@panomc/sdk": "2.0.0-dev.65",
|
|
75
|
+
"@sveltejs/adapter-node": "^6.0.0",
|
|
76
|
+
"@sveltejs/kit": "^3.1.0",
|
|
77
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
78
|
+
"sass": "^1.105.1",
|
|
79
79
|
"svelte-i18n": "^4.0.1",
|
|
80
|
-
"svelte-preprocess": "^6.0.
|
|
81
|
-
"vite": "^8.
|
|
80
|
+
"svelte-preprocess": "^6.0.5",
|
|
81
|
+
"vite": "^8.3.4"
|
|
82
82
|
},
|
|
83
83
|
"bin": {
|
|
84
84
|
"theme-core": "./bin/theme-core.js"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, mock, test } from "bun:test";
|
|
2
2
|
|
|
3
|
-
mock.module("$app/
|
|
3
|
+
mock.module("$app/env", () => ({ dev: false, building: false, browser: false }));
|
|
4
4
|
mock.module("../../lib/services/auth.js", () => ({ getCredentialsServerSide: async () => ({}) }));
|
|
5
5
|
|
|
6
6
|
const variables = await import("../../lib/variables.js");
|
package/src/kit/hooks-client.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* list) so the bundler can statically analyze them. The dev-mode assertion at
|
|
23
23
|
* the bottom guarantees this map can never drift from kit/specifiers.js.
|
|
24
24
|
*/
|
|
25
|
-
import { browser, dev } from "$app/
|
|
25
|
+
import { browser, dev } from "$app/env";
|
|
26
26
|
import { RUNTIME_SPECIFIERS } from "./specifiers.js";
|
|
27
27
|
|
|
28
28
|
const runtimeModules = {
|
package/src/kit/hooks-server.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
updateApiUrl,
|
|
25
25
|
updatePanoWebsiteUrl,
|
|
26
26
|
} from "../lib/variables.js";
|
|
27
|
-
import * as environment from "$app/
|
|
27
|
+
import * as environment from "$app/env";
|
|
28
28
|
import { getCredentialsServerSide } from "../lib/services/auth.js";
|
|
29
29
|
import { createLicenseRuntime } from "./license-runtime.js";
|
|
30
30
|
import { resolveCanonical, route } from "../registry/routes.js";
|
package/src/kit/resolve.js
CHANGED
package/src/kit/svelte-config.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* no $app imports here). A theme's config becomes:
|
|
2
|
+
* The SvelteKit options of a theme (plain-node context — no vite aliases, no $app imports here).
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* SvelteKit 3 reads its configuration from the `sveltekit()` vite plugin instead of svelte.config.js, so
|
|
5
|
+
* `createViteConfig` (kit/vite-config.js) passes these options to that plugin and a theme has no svelte.config.js.
|
|
7
6
|
*/
|
|
8
7
|
import { readFileSync } from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
9
|
import { importFromTheme } from "./resolve.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @param {string}
|
|
13
|
-
* @param {object} [overrides]
|
|
12
|
+
* @param {string} [themeDir] the theme's folder (holds its package.json); the current directory by default
|
|
13
|
+
* @param {object} [overrides] SvelteKit options merged shallowly over the defaults (e.g. `paths`, `alias`)
|
|
14
14
|
*
|
|
15
|
-
* Async on purpose
|
|
16
|
-
*
|
|
17
|
-
* only one toolchain instance exists (see kit/resolve.js).
|
|
15
|
+
* Async on purpose: the preprocessor and adapter are imported from the THEME's node_modules so only one toolchain
|
|
16
|
+
* instance exists (see kit/resolve.js).
|
|
18
17
|
*/
|
|
19
|
-
export async function
|
|
18
|
+
export async function createKitOptions(themeDir = process.cwd(), overrides = {}) {
|
|
20
19
|
const [preprocessMod, adapterMod] = await Promise.all([
|
|
21
20
|
importFromTheme("svelte-preprocess"),
|
|
22
21
|
importFromTheme("@sveltejs/adapter-node"),
|
|
@@ -24,28 +23,26 @@ export async function createSvelteConfig(themeMetaUrl, overrides = {}) {
|
|
|
24
23
|
const SveltePreprocess = preprocessMod.default ?? preprocessMod;
|
|
25
24
|
const NodeAdapter = adapterMod.default ?? adapterMod;
|
|
26
25
|
|
|
27
|
-
const pkg = JSON.parse(
|
|
28
|
-
readFileSync(new URL("./package.json", themeMetaUrl), "utf-8"),
|
|
29
|
-
);
|
|
26
|
+
const pkg = JSON.parse(readFileSync(path.join(themeDir, "package.json"), "utf-8"));
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
version
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// be reproducible: pin the version to the theme's package version.
|
|
40
|
-
name: pkg.version,
|
|
41
|
-
},
|
|
42
|
-
...overrides,
|
|
43
|
-
// `$contracts` -> plugin-contracts/ (the snapshots `theme-core contracts pull` keeps, doc 02 section 5.3):
|
|
44
|
-
// /** @type {import('$contracts/market/controllers.types.js').Controllers['market/cart']} */
|
|
45
|
-
alias: { $contracts: "plugin-contracts", ...(overrides.alias ?? {}) },
|
|
28
|
+
return {
|
|
29
|
+
adapter: NodeAdapter(),
|
|
30
|
+
version: {
|
|
31
|
+
// SvelteKit defaults version.name to Date.now(), which leaks into
|
|
32
|
+
// /_app/version.json and makes every build differ byte-for-byte. The
|
|
33
|
+
// theme zip's sha256 IS the premium license identity, so builds must
|
|
34
|
+
// be reproducible: pin the version to the theme's package version.
|
|
35
|
+
name: pkg.version,
|
|
46
36
|
},
|
|
37
|
+
...overrides,
|
|
38
|
+
// `$contracts` -> plugin-contracts/ (the snapshots `theme-core contracts pull` keeps, doc 02 section 5.3):
|
|
39
|
+
// /** @type {import('$contracts/market/controllers.types.js').Controllers['market/cart']} */
|
|
40
|
+
alias: { $contracts: "plugin-contracts", ...(overrides.alias ?? {}) },
|
|
47
41
|
|
|
48
42
|
preprocess: SveltePreprocess({
|
|
43
|
+
// Svelte 5 strips TypeScript itself; SvelteKit 3's own components are `lang="ts"` and the typescript
|
|
44
|
+
// transformer would require the typescript package in every theme.
|
|
45
|
+
typescript: false,
|
|
49
46
|
scss: {
|
|
50
47
|
api: "modern-compiler",
|
|
51
48
|
quietDeps: true,
|
|
@@ -59,7 +56,8 @@ export async function createSvelteConfig(themeMetaUrl, overrides = {}) {
|
|
|
59
56
|
}),
|
|
60
57
|
|
|
61
58
|
onwarn: (warning, handler) => {
|
|
62
|
-
|
|
59
|
+
// Svelte 5 names them a11y_*, Svelte 4 named them a11y-*
|
|
60
|
+
if (warning.code.startsWith("a11y")) {
|
|
63
61
|
return;
|
|
64
62
|
}
|
|
65
63
|
|
|
@@ -72,6 +70,15 @@ export async function createSvelteConfig(themeMetaUrl, overrides = {}) {
|
|
|
72
70
|
handler(warning);
|
|
73
71
|
},
|
|
74
72
|
};
|
|
73
|
+
}
|
|
75
74
|
|
|
76
|
-
|
|
75
|
+
/**
|
|
76
|
+
* The svelte.config.js factory of engines built for SvelteKit 2. SvelteKit 3 does not read svelte.config.js: delete
|
|
77
|
+
* the file, the options come from `createViteConfig` in vite.config.js (`kit` option for overrides).
|
|
78
|
+
*/
|
|
79
|
+
export async function createSvelteConfig() {
|
|
80
|
+
throw new Error(
|
|
81
|
+
"SvelteKit 3 does not read svelte.config.js. Delete it: createViteConfig() in vite.config.js now passes the " +
|
|
82
|
+
"SvelteKit options to the sveltekit() plugin (put overrides such as `paths` under its `kit` option).",
|
|
83
|
+
);
|
|
77
84
|
}
|
package/src/kit/vite-config.js
CHANGED
|
@@ -16,6 +16,7 @@ import { createRequire } from "node:module";
|
|
|
16
16
|
import { createHash } from "node:crypto";
|
|
17
17
|
import { pathToFileURL } from "node:url";
|
|
18
18
|
import { importFromTheme } from "./resolve.js";
|
|
19
|
+
import { createKitOptions } from "./svelte-config.js";
|
|
19
20
|
import { scanThemeMeta, renderThemeMetaModule } from "./theme-meta.js";
|
|
20
21
|
import { loadThemeConfig, pullContracts, writeCoreMeta } from "../../bin/contracts.js";
|
|
21
22
|
|
|
@@ -30,7 +31,9 @@ function copyFolderPlugin(folder) {
|
|
|
30
31
|
configResolved() {
|
|
31
32
|
outDir = "build/";
|
|
32
33
|
},
|
|
33
|
-
|
|
34
|
+
// SvelteKit 3 runs the adapter in a post `buildApp` hook, after every closeBundle, and adapter-node empties
|
|
35
|
+
// build/ first: a copy into build/ must run after it (this plugin comes after sveltekit() in the list).
|
|
36
|
+
buildApp: { order: "post", async handler() {
|
|
34
37
|
const srcDir = path.resolve(process.cwd(), folder);
|
|
35
38
|
const destDir = path.resolve(process.cwd(), outDir, folder);
|
|
36
39
|
|
|
@@ -45,7 +48,7 @@ function copyFolderPlugin(folder) {
|
|
|
45
48
|
} catch (error) {
|
|
46
49
|
console.error(`Error copying "${folder}" folder:`, error);
|
|
47
50
|
}
|
|
48
|
-
},
|
|
51
|
+
} },
|
|
49
52
|
};
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -58,7 +61,9 @@ export function copyManifestPlugin(filename = "manifest.json") {
|
|
|
58
61
|
configResolved() {
|
|
59
62
|
outDir = "build/";
|
|
60
63
|
},
|
|
61
|
-
|
|
64
|
+
// SvelteKit 3 runs the adapter in a post `buildApp` hook, after every closeBundle, and adapter-node empties
|
|
65
|
+
// build/ first: a copy into build/ must run after it (this plugin comes after sveltekit() in the list).
|
|
66
|
+
buildApp: { order: "post", async handler() {
|
|
62
67
|
const srcPath = path.resolve(process.cwd(), filename);
|
|
63
68
|
const destPath = path.resolve(process.cwd(), outDir, filename);
|
|
64
69
|
|
|
@@ -73,7 +78,7 @@ export function copyManifestPlugin(filename = "manifest.json") {
|
|
|
73
78
|
} catch (err) {
|
|
74
79
|
console.error("Failed to copy manifest.json:", err);
|
|
75
80
|
}
|
|
76
|
-
},
|
|
81
|
+
} },
|
|
77
82
|
};
|
|
78
83
|
}
|
|
79
84
|
|
|
@@ -113,7 +118,9 @@ export function copyCoreMetaPlugin() {
|
|
|
113
118
|
configResolved() {
|
|
114
119
|
outDir = "build/";
|
|
115
120
|
},
|
|
116
|
-
|
|
121
|
+
// SvelteKit 3 runs the adapter in a post `buildApp` hook, after every closeBundle, and adapter-node empties
|
|
122
|
+
// build/ first: a copy into build/ must run after it (this plugin comes after sveltekit() in the list).
|
|
123
|
+
buildApp: { order: "post", async handler() {
|
|
117
124
|
const themeDir = process.cwd();
|
|
118
125
|
const destPath = path.resolve(themeDir, outDir, "core-meta.json");
|
|
119
126
|
const corePkg = require("@panomc/theme-core/package.json");
|
|
@@ -136,7 +143,7 @@ export function copyCoreMetaPlugin() {
|
|
|
136
143
|
|
|
137
144
|
writeCoreMeta({ themeDir, config, outFile: destPath, extra: { coreVersion: corePkg.version } });
|
|
138
145
|
console.log(`Wrote core-meta.json (coreVersion ${corePkg.version})`);
|
|
139
|
-
},
|
|
146
|
+
} },
|
|
140
147
|
};
|
|
141
148
|
}
|
|
142
149
|
|
|
@@ -238,8 +245,10 @@ function corePackageSrc() {
|
|
|
238
245
|
|
|
239
246
|
/**
|
|
240
247
|
* @param {object} [opts]
|
|
241
|
-
* @param {string} [opts.base] app base path ("" for themes, "/panel" for panel-ui);
|
|
242
|
-
*
|
|
248
|
+
* @param {string} [opts.base] app base path ("" for themes, "/panel" for panel-ui); SvelteKit's
|
|
249
|
+
* `paths.base`, the sdk's `base` (`__PANO_BASE_PATH__`), the extra dev proxy entry and the hmr path
|
|
250
|
+
* @param {object} [opts.kit] SvelteKit options merged over the engine's (kit/svelte-config.js); SvelteKit 3
|
|
251
|
+
* takes them in the sveltekit() vite plugin, a theme has no svelte.config.js
|
|
243
252
|
* @param {string[]} [opts.copyFolders] folders copied into build/ (default lang+screenshots;
|
|
244
253
|
* panel: ["lang"])
|
|
245
254
|
* @param {object} [opts.extraAliases] additional resolve.alias entries
|
|
@@ -259,6 +268,11 @@ export function createViteConfig(opts = {}) {
|
|
|
259
268
|
// copy can be a different version and would drive the build with mismatched
|
|
260
269
|
// $app/runtime code (see kit/resolve.js).
|
|
261
270
|
const { sveltekit } = await importFromTheme("@sveltejs/kit", "./vite");
|
|
271
|
+
const kitOverrides = opts.kit ?? {};
|
|
272
|
+
const kitOptions = await createKitOptions(process.cwd(), {
|
|
273
|
+
...kitOverrides,
|
|
274
|
+
...(base ? { paths: { ...(kitOverrides.paths ?? {}), base } } : {}),
|
|
275
|
+
});
|
|
262
276
|
|
|
263
277
|
// Every dev start refreshes plugin-contracts/ from the installed plugins and prints the views whose
|
|
264
278
|
// contract changed (doc 01 section 5). Never fatal: a broken plugin folder must not stop the dev server.
|
|
@@ -274,7 +288,7 @@ export function createViteConfig(opts = {}) {
|
|
|
274
288
|
clearScreen: false,
|
|
275
289
|
plugins: [
|
|
276
290
|
panoThemeMeta(),
|
|
277
|
-
sveltekit(),
|
|
291
|
+
sveltekit(kitOptions),
|
|
278
292
|
// NOTE: licenses.json is generated by bin/license/finalize-fingerprint.js
|
|
279
293
|
// AFTER vite build — a closeBundle plugin races adapter-node's build/
|
|
280
294
|
// rewrite (SSR pass's output gets wiped by the final adapter pass).
|
|
@@ -346,8 +360,16 @@ export function createViteConfig(opts = {}) {
|
|
|
346
360
|
path: base ? `${base}/` : "/",
|
|
347
361
|
},
|
|
348
362
|
},
|
|
363
|
+
define: {
|
|
364
|
+
// the sdk's `base` (@panomc/sdk/core/js/basePath.js): `$app/paths` has no `base` since SvelteKit 3
|
|
365
|
+
__PANO_BASE_PATH__: JSON.stringify(base),
|
|
366
|
+
},
|
|
349
367
|
resolve: {
|
|
350
368
|
alias: {
|
|
369
|
+
// SvelteKit 3 no longer defines `$lib`. The engine and the sdk import the theme's own modules through it
|
|
370
|
+
// ("host-provides": $lib/variables.js, $lib/Store.js, ...), and a subpath import (`#lib`) would resolve
|
|
371
|
+
// against the importing package, not the theme, so it stays a vite alias.
|
|
372
|
+
"$lib": path.resolve(process.cwd(), "src/lib"),
|
|
351
373
|
// $pano resolves core-internal imports; it works in every
|
|
352
374
|
// vite-processed context (theme code, core code, generated shims).
|
|
353
375
|
"$pano": corePackageSrc(),
|
package/src/lib/PluginAPI.js
CHANGED
|
@@ -5,7 +5,7 @@ import { sortSiteNavLinks } from "./orderNavLinks.util.js";
|
|
|
5
5
|
import { addPluginListener, resetPluginListeners } from "@panomc/sdk/core/js/NotificationManager.js";
|
|
6
6
|
import { avatarVersion } from "./Store.js";
|
|
7
7
|
import { controllers } from "@panomc/sdk/core/js/ControllerRegistry.js";
|
|
8
|
-
import { browser } from "$app/
|
|
8
|
+
import { browser } from "$app/env";
|
|
9
9
|
import { redirect } from "@sveltejs/kit";
|
|
10
10
|
// Engine-internal imports are relative: they resolve to the same files as the `$pano/...` alias, and a
|
|
11
11
|
// module that holds state (the registry) must be one instance whichever spelling reaches it.
|
|
@@ -162,11 +162,28 @@ function toPublicUrl(url) {
|
|
|
162
162
|
return typeof url === "string" && url.startsWith("/") && !url.startsWith("//") ? route(url) : url;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
/**
|
|
166
|
+
* SvelteKit 3 renamed `goto` options; a plugin built for SvelteKit 2 still passes the old names, which SvelteKit 3
|
|
167
|
+
* would ignore. The old names are mapped onto the new ones (a new name the caller set wins).
|
|
168
|
+
*/
|
|
169
|
+
function kit3GotoOptions(options) {
|
|
170
|
+
if (!options || typeof options !== "object") return options;
|
|
171
|
+
|
|
172
|
+
const { replaceState, invalidateAll, keepFocus, noScroll, ...rest } = options;
|
|
173
|
+
const mapped = { ...rest };
|
|
174
|
+
|
|
175
|
+
if (replaceState !== undefined && mapped.replace === undefined) mapped.replace = replaceState;
|
|
176
|
+
if (invalidateAll !== undefined && mapped.refreshAll === undefined) mapped.refreshAll = invalidateAll;
|
|
177
|
+
if ((keepFocus || noScroll) && mapped.reset === undefined) mapped.reset = false;
|
|
178
|
+
|
|
179
|
+
return mapped;
|
|
180
|
+
}
|
|
181
|
+
|
|
165
182
|
/** `goto` for plugins: a renamed route lands on its public path. */
|
|
166
183
|
export async function routedGoto(url, options) {
|
|
167
184
|
const { goto } = await import("$app/navigation");
|
|
168
185
|
|
|
169
|
-
return goto(toPublicUrl(url), options);
|
|
186
|
+
return goto(toPublicUrl(url), kit3GotoOptions(options));
|
|
170
187
|
}
|
|
171
188
|
|
|
172
189
|
/** `redirect` for plugins (throws like SvelteKit's): a renamed route lands on its public path. */
|
|
@@ -22,7 +22,7 @@ const panoApiStub = {
|
|
|
22
22
|
auth: { loginUrl: (returnTo) => `/login?redirect=${returnTo ?? ""}` },
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const setEnvironment = (browser) => mock.module("$app/
|
|
25
|
+
const setEnvironment = (browser) => mock.module("$app/env", () => ({ browser, dev: false }));
|
|
26
26
|
|
|
27
27
|
// bun mocks are process-wide, a module that is already linked cannot gain exports, and suites loaded later
|
|
28
28
|
// replace what this one installed: every stub is a superset of the others', and all of them are installed
|
|
@@ -325,7 +325,7 @@ describe("browser host", () => {
|
|
|
325
325
|
h.navigate("/store/vip", { replace: true });
|
|
326
326
|
expect(calls.gotos).toEqual([
|
|
327
327
|
{ url: "/store", options: undefined },
|
|
328
|
-
{ url: "/store/vip", options: {
|
|
328
|
+
{ url: "/store/vip", options: { replace: true } },
|
|
329
329
|
]);
|
|
330
330
|
});
|
|
331
331
|
});
|
|
@@ -15,13 +15,13 @@ import skinContract from "../../../skin-contract.json" with { type: "json" };
|
|
|
15
15
|
const lib = resolve(import.meta.dir, "..");
|
|
16
16
|
const src = resolve(lib, "..");
|
|
17
17
|
|
|
18
|
-
mock.module("$app/
|
|
18
|
+
mock.module("$app/env", () => ({ browser: false, dev: false }));
|
|
19
19
|
|
|
20
20
|
const state = (globalThis.__cx03 = { answers: {}, calls: [] });
|
|
21
21
|
|
|
22
22
|
const STUBS = {
|
|
23
23
|
svelte: `export const onMount = () => {}; export const onDestroy = () => {};`,
|
|
24
|
-
"$app/
|
|
24
|
+
"$app/env": `export const browser = false; export const dev = false;`,
|
|
25
25
|
"$pano/lib/api.util.js": `const s = globalThis.__cx03;
|
|
26
26
|
export const NETWORK_ERROR = "NETWORK_ERROR";
|
|
27
27
|
export default { get: async ({ path }) => { s.calls.push(path); return s.answers[path] ?? { error: true }; }, delete: async () => ({}) };`,
|
|
@@ -4,7 +4,7 @@ import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
|
4
4
|
// views (so a theme's override of Main, Sidebar ... resolves through loadView), and a plugin page declared
|
|
5
5
|
// with `controller` and no `load` gets the controller's data.
|
|
6
6
|
|
|
7
|
-
mock.module("$app/
|
|
7
|
+
mock.module("$app/env", () => ({ dev: false, browser: false }));
|
|
8
8
|
mock.module("@sveltejs/kit", () => ({
|
|
9
9
|
error: (status, message) => Object.assign(new Error(`HTTP ${status} ${message ?? ""}`), { status }),
|
|
10
10
|
redirect: (status, location) => Object.assign(new Error("redirect"), { status, location, redirect: true }),
|
|
@@ -26,7 +26,8 @@ export function findSvelte() {
|
|
|
26
26
|
const STUB_JS = {
|
|
27
27
|
"svelte-i18n": `import { readable } from "svelte/store";
|
|
28
28
|
export const _ = readable((key, options) => (options && options.values && Object.keys(options.values).length ? key + JSON.stringify(options.values) : key));`,
|
|
29
|
-
"$app/
|
|
29
|
+
"$app/env": `export const dev = false; export const browser = false;`,
|
|
30
|
+
"@panomc/sdk/core/js/basePath.js": `export const base = "";`,
|
|
30
31
|
"@theme-style": `export {};`,
|
|
31
32
|
// ViewComponent reads the pano context for wrapInjected; without one it renders the module as before
|
|
32
33
|
"@panomc/sdk/internal": `export const getPanoContext = () => ({});`,
|
|
@@ -7,7 +7,7 @@ import { writable } from "svelte/store";
|
|
|
7
7
|
import { buildCases, findSvelte, mainContext, renderAll, renderPart } from "./engineParts.helper.js";
|
|
8
8
|
|
|
9
9
|
// The registry reads SvelteKit's `dev` flag.
|
|
10
|
-
mock.module("$app/
|
|
10
|
+
mock.module("$app/env", () => ({ browser: false, dev: false }));
|
|
11
11
|
|
|
12
12
|
const registry = await import("../../registry/index.js");
|
|
13
13
|
|
|
@@ -43,9 +43,9 @@ export const executeSidebarLoad = async () => {};`;
|
|
|
43
43
|
const STUB_JS = {
|
|
44
44
|
"svelte-i18n": `import { readable } from "svelte/store";
|
|
45
45
|
export const _ = readable((key, options) => (options && options.values && Object.keys(options.values).length ? key + JSON.stringify(options.values) : key));`,
|
|
46
|
-
"$app/
|
|
47
|
-
"
|
|
48
|
-
"
|
|
46
|
+
"$app/env": `export const dev = false; export const browser = false;`,
|
|
47
|
+
"@panomc/sdk/core/js/appStores.js": `import { readable } from "svelte/store"; export const page = readable({ url: { pathname: "/profile" } });`,
|
|
48
|
+
"@panomc/sdk/core/js/basePath.js": `export const base = "";`,
|
|
49
49
|
"copy-to-clipboard": `export default function copy() {}`,
|
|
50
50
|
"$pano/lib/tooltip.util": `export default function tooltip() {}`,
|
|
51
51
|
"$pano/lib/Store": `import { readable } from "svelte/store";
|
|
@@ -12,7 +12,7 @@ import { buildSidebarCases, openSession, renderAllSidebars, renderSidebarCase }
|
|
|
12
12
|
// go through route().
|
|
13
13
|
|
|
14
14
|
// The registry reads SvelteKit's `dev` flag.
|
|
15
|
-
mock.module("$app/
|
|
15
|
+
mock.module("$app/env", () => ({ browser: false, dev: false }));
|
|
16
16
|
|
|
17
17
|
const registry = await import("../../registry/index.js");
|
|
18
18
|
const routes = await import("../../registry/routes.js");
|
|
@@ -38,13 +38,13 @@ mock.module("@sveltejs/kit", () => ({
|
|
|
38
38
|
error: (status, message) => Object.assign(new Error(`HTTP ${status} ${message ?? ""}`), { status }),
|
|
39
39
|
}));
|
|
40
40
|
mock.module("$app/paths", () => ({ base: "" }));
|
|
41
|
-
mock.module("$app/
|
|
41
|
+
mock.module("$app/env", () => ({ browser: false, dev: false }));
|
|
42
42
|
mock.module("$app/navigation", () => ({
|
|
43
43
|
goto: async () => {},
|
|
44
44
|
invalidate: async () => {},
|
|
45
45
|
invalidateAll: async () => {},
|
|
46
46
|
}));
|
|
47
|
-
mock.module("
|
|
47
|
+
mock.module("@panomc/sdk/core/js/appStores.js", () => ({ page: pageStore, navigating: writable(null), captureRequestState: () => {} }));
|
|
48
48
|
mock.module("$pano/lib/services/auth.js", () => ({ sendLogout: async () => {} }));
|
|
49
49
|
mock.module("$pano/lib/components/ToastContainer.svelte", () => ({
|
|
50
50
|
show: async () => {},
|
|
@@ -236,9 +236,9 @@ function target_(spec, from, mode = "server") {
|
|
|
236
236
|
if (mode === "client") {
|
|
237
237
|
// the client build runs under bun: the browser entry of Svelte and a stub for the aliases
|
|
238
238
|
if (spec === "svelte") return join(svelteDir, "src", "index-client.js");
|
|
239
|
-
if (spec === "$app/
|
|
240
|
-
if (spec === "
|
|
241
|
-
return clientStub("stores", "export const page = { subscribe(run) { run(globalThis.__engineWiringClientPage); return () => {}; } };");
|
|
239
|
+
if (spec === "$app/env") return clientStub("environment", "export const browser = true; export const dev = false;");
|
|
240
|
+
if (spec === "@panomc/sdk/core/js/appStores.js") {
|
|
241
|
+
return clientStub("stores", "export const page = { subscribe(run) { run(globalThis.__engineWiringClientPage); return () => {}; } }; export const navigating = { subscribe(run) { run(null); return () => {}; } }; export const captureRequestState = () => {};");
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
if (spec === "svelte" || spec.startsWith("svelte/")) return spec;
|
|
@@ -823,8 +823,8 @@ describe("AppLayoutLogics wiring", () => {
|
|
|
823
823
|
["$pano/lib/PluginAPI", PLUGIN_API_SPEC],
|
|
824
824
|
["@panomc/sdk/internal", Bun.resolveSync("@panomc/sdk/internal", pkgSrc)],
|
|
825
825
|
["svelte/store", "svelte/store"],
|
|
826
|
-
["
|
|
827
|
-
["
|
|
826
|
+
["@panomc/sdk/core/js/appStores.js", "@panomc/sdk/core/js/appStores.js"],
|
|
827
|
+
["@panomc/sdk/core/js/basePath.js", "@panomc/sdk/core/js/basePath.js"],
|
|
828
828
|
["@sveltejs/kit", "@sveltejs/kit"],
|
|
829
829
|
["$app/navigation", "$app/navigation"],
|
|
830
830
|
]);
|
|
@@ -856,7 +856,7 @@ describe("AppLayoutLogics wiring", () => {
|
|
|
856
856
|
"const bindControllerSession = (session) => { __s.bound.push(session); return () => {}; };",
|
|
857
857
|
].join("\n");
|
|
858
858
|
}
|
|
859
|
-
if (from === "$app/
|
|
859
|
+
if (from === "$app/env") return `const browser = ${browser}; const dev = false;`;
|
|
860
860
|
return lines.join("\n");
|
|
861
861
|
};
|
|
862
862
|
|
|
@@ -40,13 +40,13 @@ mock.module("@sveltejs/kit", () => ({
|
|
|
40
40
|
error: (status, message) => Object.assign(new Error(`HTTP ${status} ${message ?? ""}`), { status }),
|
|
41
41
|
}));
|
|
42
42
|
mock.module("$app/paths", () => ({ base: "" }));
|
|
43
|
-
mock.module("$app/
|
|
43
|
+
mock.module("$app/env", () => ({ browser: false, dev: false }));
|
|
44
44
|
mock.module("$app/navigation", () => ({
|
|
45
45
|
goto: async () => {},
|
|
46
46
|
invalidate: async () => {},
|
|
47
47
|
invalidateAll: async () => {},
|
|
48
48
|
}));
|
|
49
|
-
mock.module("
|
|
49
|
+
mock.module("@panomc/sdk/core/js/appStores.js", () => ({ page: pageStore, navigating: writable(null), captureRequestState: () => {} }));
|
|
50
50
|
|
|
51
51
|
const registry = await import("../../registry/index.js");
|
|
52
52
|
const { createViewProxy } = await import("../../../../sdk/src/views.js");
|
|
@@ -557,10 +557,10 @@ function emitClientFallbackStyles() {
|
|
|
557
557
|
function target_(spec, from, mode) {
|
|
558
558
|
if (mode === "client") {
|
|
559
559
|
if (spec === "svelte") return join(svelteDir, "src", "index-client.js");
|
|
560
|
-
if (spec === "$app/
|
|
560
|
+
if (spec === "$app/env") return clientStub("environment", "export const browser = true; export const dev = false;");
|
|
561
561
|
if (spec === "$app/paths") return clientStub("paths", 'export const base = "";');
|
|
562
|
-
if (spec === "
|
|
563
|
-
return clientStub("stores", "export const page = { subscribe(run) { run(globalThis.__tc53ClientPage); return () => {}; } };");
|
|
562
|
+
if (spec === "@panomc/sdk/core/js/appStores.js") {
|
|
563
|
+
return clientStub("stores", "export const page = { subscribe(run) { run(globalThis.__tc53ClientPage); return () => {}; } }; export const navigating = { subscribe(run) { run(null); return () => {}; } }; export const captureRequestState = () => {};");
|
|
564
564
|
}
|
|
565
565
|
}
|
|
566
566
|
|
|
@@ -11,7 +11,7 @@ import { buildCases, renderPart } from "./engineParts.helper.js";
|
|
|
11
11
|
// `/posts` route, and `route()` in the default views.
|
|
12
12
|
|
|
13
13
|
// bun mocks are process-wide: every stub is a superset of what the other suites use
|
|
14
|
-
mock.module("$app/
|
|
14
|
+
mock.module("$app/env", () => ({ browser: false, dev: false }));
|
|
15
15
|
mock.module("@sveltejs/kit", () => ({
|
|
16
16
|
error: (status, message) => Object.assign(new Error(`HTTP ${status} ${message ?? ""}`), { status }),
|
|
17
17
|
redirect: (status, location) => Object.assign(new Error("redirect"), { status, location, redirect: true }),
|