-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move themes to @presenter/themes package
Also enable no-cors
- Loading branch information
1 parent
6c149da
commit 3092bad
Showing
41 changed files
with
89 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
import { copyFile } from 'node:fs/promises' | ||
import { join } from 'node:path' | ||
|
||
import { CUSTOM_OVERLAY_THEMES_FOLDER, CUSTOM_THEMES_FOLDER } from '@presenter/node' | ||
import { USER_OVERLAY_THEMES_FOLDER, USER_PRESENTER_THEMES_FOLDER } from '@presenter/node' | ||
import express, { Application } from 'express' | ||
|
||
import { FRONTEND_OVERLAY_THEMES_FOLDER, FRONTEND_THEMES_FOLDER } from '~/helpers/consts' | ||
import { OVERLAY_THEMES_FOLDER, PRESENTER_THEMES_FOLDER } from '~/helpers/consts' | ||
|
||
import createApi from './api' | ||
import { getOverlayThemeNames, getPresenterThemeNames } from './themes' | ||
|
||
const copyExampleThemes = () => Promise.all( [ | ||
[ FRONTEND_OVERLAY_THEMES_FOLDER, CUSTOM_OVERLAY_THEMES_FOLDER ], | ||
[ FRONTEND_THEMES_FOLDER, CUSTOM_THEMES_FOLDER ], | ||
[ OVERLAY_THEMES_FOLDER, USER_OVERLAY_THEMES_FOLDER ], | ||
[ PRESENTER_THEMES_FOLDER, USER_PRESENTER_THEMES_FOLDER ], | ||
].map( ( [ src, dest ] ) => copyFile( | ||
join( src, 'Example.template' ), | ||
join( dest, 'Example.css' ), | ||
) ) ) | ||
|
||
const mounts = [ | ||
[ '/presenter/themes', FRONTEND_THEMES_FOLDER ], | ||
[ '/presenter/themes', CUSTOM_THEMES_FOLDER ], | ||
[ '/presenter/themes/*', join( FRONTEND_OVERLAY_THEMES_FOLDER, 'Day.css' ) ], | ||
[ '/overlay/themes', FRONTEND_OVERLAY_THEMES_FOLDER ], | ||
[ '/overlay/themes/', CUSTOM_OVERLAY_THEMES_FOLDER ], | ||
[ 'presenter', PRESENTER_THEMES_FOLDER ], | ||
[ 'presenter', USER_PRESENTER_THEMES_FOLDER ], | ||
[ 'overlay', OVERLAY_THEMES_FOLDER ], | ||
[ 'overlay', USER_OVERLAY_THEMES_FOLDER ], | ||
] as const | ||
|
||
type ThemesModuleOptions = { | ||
api: Application, | ||
} | ||
|
||
const createThemesModule = async ( { api }: ThemesModuleOptions ) => { | ||
mounts.forEach( ( [ prefix, dir ] ) => api.use( prefix, express.static( dir ) ) ) | ||
mounts.forEach( ( [ prefix, dir ] ) => api.use( `/themes/${prefix}`, express.static( dir ) ) ) | ||
|
||
api.use( createApi() ) | ||
api.get( '/themes/presenter', ( _, res ) => void getPresenterThemeNames().then( ( r ) => res.json( r ) ) ) | ||
api.get( '/themes/overlay', ( _, res ) => void getOverlayThemeNames().then( ( r ) => res.json( r ) ) ) | ||
|
||
// TODO: uncomment when we have a way to copy example themes | ||
// await copyExampleThemes() | ||
await copyExampleThemes() | ||
} | ||
|
||
export default createThemesModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
{ | ||
"name": "@presenter/themes", | ||
"private": true, | ||
"type": "module" | ||
"type": "module", | ||
"exports": { | ||
".": "./package.json", | ||
"./overlay": "./overlay", | ||
"./overlay/*": "./overlay/*", | ||
"./presenter": "./presenter", | ||
"./presenter/*": "./presenter/*" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes