@ossy/app 1.15.0 → 1.15.2

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.
@@ -1,5 +0,0 @@
1
- /**
2
- * Default config when src/config.js does not exist.
3
- * Provides empty defaults so the server can always merge config.
4
- */
5
- export default {}
@@ -1,8 +0,0 @@
1
- import path from 'path'
2
-
3
- export function staticHtmlPathForRoute (routePath, publicDir) {
4
- const segments = routePath === '/' ? [] : routePath.replace(/^\//, '').split('/')
5
- return path.join(publicDir, ...segments, 'index.html')
6
- }
7
-
8
- export default { type: '@ossy/app/prerender-react' }
@@ -1,51 +0,0 @@
1
- import { renderPage as ssrRender } from '../ssr/app.mjs'
2
-
3
- export function buildPrerenderAppConfig ({
4
- buildTimeConfig,
5
- pageList,
6
- activeRouteId,
7
- urlPath,
8
- isAuthenticated = false,
9
- }) {
10
- const pages = pageList.map((page) => ({
11
- id: page?.id,
12
- path: page?.path,
13
- }))
14
- return {
15
- ...buildTimeConfig,
16
- url: urlPath,
17
- theme: buildTimeConfig.theme || 'light',
18
- isAuthenticated,
19
- workspaceId: buildTimeConfig.workspaceId,
20
- apiUrl: buildTimeConfig.apiUrl,
21
- pages,
22
- pageId: activeRouteId,
23
- sidebarPrimaryCollapsed: false,
24
- }
25
- }
26
-
27
- function jsonSafeClone (value) {
28
- if (value == null || typeof value !== 'object') return value
29
- try {
30
- return JSON.parse(JSON.stringify(value))
31
- } catch {
32
- return value
33
- }
34
- }
35
-
36
- export function buildHydrationAppConfig (appConfig) {
37
- if (!appConfig || typeof appConfig !== 'object') return appConfig
38
- return {
39
- ...appConfig,
40
- theme: jsonSafeClone(appConfig.theme),
41
- themes: jsonSafeClone(appConfig.themes),
42
- resourceTemplates: jsonSafeClone(appConfig.resourceTemplates),
43
- }
44
- }
45
-
46
- export const BuildPage = {
47
- async handle ({ route, appConfig }) {
48
- const config = buildHydrationAppConfig(appConfig)
49
- return ssrRender(route.id, config, {})
50
- },
51
- }
@@ -1,35 +0,0 @@
1
- import fs from 'fs'
2
- import path from 'path'
3
- import { fileURLToPath } from 'url'
4
-
5
- const STUBS = [
6
- ['middleware.js', 'export default []\n'],
7
- ]
8
-
9
- /** Ensures build/middleware.js exists when Rollup omits an empty middleware chunk. */
10
- export function ensureBuildStubs(buildDir) {
11
- if (!fs.existsSync(buildDir)) {
12
- console.warn(`[ensure-build-stubs] skip: ${buildDir} missing`)
13
- return
14
- }
15
- for (const [name, content] of STUBS) {
16
- const filePath = path.join(buildDir, name)
17
- if (!fs.existsSync(filePath)) {
18
- fs.writeFileSync(filePath, content)
19
- console.log(`[ensure-build-stubs] wrote ${name} (rollup omitted empty chunk)`)
20
- }
21
- }
22
- }
23
-
24
- const isMain =
25
- process.argv[1] &&
26
- path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
27
-
28
- if (isMain) {
29
- const buildDir = path.join(process.cwd(), 'build')
30
- if (!fs.existsSync(buildDir)) {
31
- console.error('[ensure-build-stubs] build/ missing; run build first')
32
- process.exit(1)
33
- }
34
- ensureBuildStubs(buildDir)
35
- }