create-lupine 1.0.30 → 1.2.0

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.
Files changed (127) hide show
  1. package/README.md +25 -0
  2. package/index.js +35 -13
  3. package/package.json +1 -1
  4. package/templates/common/.agents/skills/lupine-framework/SKILL.md +63 -0
  5. package/templates/common/.agents/skills/lupine-framework/references/backend-api.md +98 -0
  6. package/templates/common/.agents/skills/lupine-framework/references/icon-handling.md +71 -0
  7. package/templates/common/.agents/skills/lupine-framework/references/mobile-interactions.md +100 -0
  8. package/templates/common/.agents/skills/lupine-framework/references/native-apps.md +167 -0
  9. package/templates/common/.agents/skills/lupine-framework/references/navigation-and-routing.md +54 -0
  10. package/templates/common/.agents/skills/lupine-framework/references/reactivity-and-state.md +108 -0
  11. package/templates/common/.agents/skills/lupine-framework/references/styling-and-themes.md +119 -0
  12. package/templates/common/_env +12 -2
  13. package/templates/common/apps/server/src/index.ts +2 -1
  14. package/templates/lupine-template-cv-starter/README.md +5 -0
  15. package/templates/lupine-template-cv-starter/web/src/index.tsx +1 -10
  16. package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.tsx +1 -10
  17. package/templates/lupine-template-doc-starter/README.md +5 -0
  18. package/templates/lupine-template-doc-starter/web/src/index.tsx +1 -10
  19. package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.tsx +1 -10
  20. package/templates/lupine-template-fullstack-starter/README.md +21 -0
  21. package/templates/lupine-template-fullstack-starter/api/package.json +10 -0
  22. package/templates/lupine-template-fullstack-starter/api/resources/install.mysql.sql +107 -0
  23. package/templates/lupine-template-fullstack-starter/api/resources/install.sqlite.sql +75 -0
  24. package/templates/lupine-template-fullstack-starter/api/src/lang/api-lang-en.ts +39 -0
  25. package/templates/lupine-template-fullstack-starter/api/src/lang/api-lang-zh-cn.ts +37 -0
  26. package/templates/lupine-template-fullstack-starter/api/src/service/admin-api.ts +139 -0
  27. package/templates/lupine-template-fullstack-starter/api/src/service/api.ts +111 -0
  28. package/templates/lupine-template-fullstack-starter/api/src/service/contact-api.ts +50 -0
  29. package/templates/lupine-template-fullstack-starter/api/src/service/file-api-base.ts +30 -0
  30. package/templates/lupine-template-fullstack-starter/api/src/service/root-api.ts +28 -0
  31. package/templates/lupine-template-fullstack-starter/api/src/service/send-email.ts +47 -0
  32. package/templates/lupine-template-fullstack-starter/api/src/service/setting-api.ts +60 -0
  33. package/templates/lupine-template-fullstack-starter/api/src/service/user-api.ts +1041 -0
  34. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/lupine.json +10 -1
  35. package/templates/lupine-template-fullstack-starter/web/assets/android-chrome-192x192.png +0 -0
  36. package/templates/lupine-template-fullstack-starter/web/assets/apple-touch-icon.png +0 -0
  37. package/templates/lupine-template-fullstack-starter/web/assets/favicon-16x16.png +0 -0
  38. package/templates/lupine-template-fullstack-starter/web/assets/favicon-32x32.png +0 -0
  39. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/License-carbon-icons.txt +71 -0
  40. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/License-material-design.txt +20 -0
  41. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/i-font.woff2 +0 -0
  42. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/sample.html +124 -0
  43. package/templates/lupine-template-fullstack-starter/web/assets/icons-font/style.css +103 -0
  44. package/templates/lupine-template-fullstack-starter/web/assets/images/sample.png +0 -0
  45. package/templates/lupine-template-fullstack-starter/web/assets/lupine-flower.png +0 -0
  46. package/templates/lupine-template-fullstack-starter/web/assets/lupine.svg +71 -0
  47. package/templates/lupine-template-fullstack-starter/web/assets/site.webmanifest +14 -0
  48. package/templates/lupine-template-fullstack-starter/web/icons-font.config.js +129 -0
  49. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/package.json +1 -1
  50. package/templates/lupine-template-fullstack-starter/web/src/admin_dev/admin-about.tsx +16 -0
  51. package/templates/lupine-template-fullstack-starter/web/src/admin_dev/admin-patch.ts +22 -0
  52. package/templates/lupine-template-fullstack-starter/web/src/admin_dev/index.html +22 -0
  53. package/templates/lupine-template-fullstack-starter/web/src/admin_dev/index.tsx +64 -0
  54. package/templates/lupine-template-fullstack-starter/web/src/components/footer-menu.tsx +52 -0
  55. package/templates/lupine-template-fullstack-starter/web/src/components/footer.tsx +15 -0
  56. package/templates/lupine-template-fullstack-starter/web/src/components/header.tsx +75 -0
  57. package/templates/lupine-template-fullstack-starter/web/src/components/home-search-component.tsx +132 -0
  58. package/templates/lupine-template-fullstack-starter/web/src/components/login-code-zh.tsx +162 -0
  59. package/templates/lupine-template-fullstack-starter/web/src/components/login-code.tsx +165 -0
  60. package/templates/lupine-template-fullstack-starter/web/src/components/login-zh.tsx +118 -0
  61. package/templates/lupine-template-fullstack-starter/web/src/components/login.tsx +122 -0
  62. package/templates/lupine-template-fullstack-starter/web/src/components/not-found-page.tsx +12 -0
  63. package/templates/lupine-template-fullstack-starter/web/src/components/register-zh.tsx +161 -0
  64. package/templates/lupine-template-fullstack-starter/web/src/components/register.tsx +163 -0
  65. package/templates/lupine-template-fullstack-starter/web/src/components/reset-password-zh.tsx +166 -0
  66. package/templates/lupine-template-fullstack-starter/web/src/components/reset-password.tsx +177 -0
  67. package/templates/lupine-template-fullstack-starter/web/src/components/story-card.tsx +96 -0
  68. package/templates/lupine-template-fullstack-starter/web/src/components/story-list.tsx +106 -0
  69. package/templates/lupine-template-fullstack-starter/web/src/components/story-props.ts +34 -0
  70. package/templates/lupine-template-fullstack-starter/web/src/components/user-info.tsx +84 -0
  71. package/templates/lupine-template-fullstack-starter/web/src/frames/admin-page-frame.tsx +48 -0
  72. package/templates/lupine-template-fullstack-starter/web/src/frames/frame1-page-frame.tsx +61 -0
  73. package/templates/lupine-template-fullstack-starter/web/src/frames/frame2-page-frame.tsx +61 -0
  74. package/templates/lupine-template-fullstack-starter/web/src/frames/top-frame.tsx +23 -0
  75. package/templates/lupine-template-fullstack-starter/web/src/frames/user-page-frame.tsx +90 -0
  76. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/index.html +6 -0
  77. package/templates/lupine-template-fullstack-starter/web/src/index.tsx +155 -0
  78. package/templates/lupine-template-fullstack-starter/web/src/models/client-env-keys.ts +5 -0
  79. package/templates/lupine-template-fullstack-starter/web/src/models/index.ts +15 -0
  80. package/templates/lupine-template-fullstack-starter/web/src/pages/admin-cfg.tsx +140 -0
  81. package/templates/lupine-template-fullstack-starter/web/src/pages/admin-item-edit.tsx +21 -0
  82. package/templates/lupine-template-fullstack-starter/web/src/pages/admin-item-list.tsx +24 -0
  83. package/templates/lupine-template-fullstack-starter/web/src/pages/admin-user.tsx +150 -0
  84. package/templates/lupine-template-fullstack-starter/web/src/pages/contact.tsx +105 -0
  85. package/templates/lupine-template-fullstack-starter/web/src/pages/page1-page.tsx +38 -0
  86. package/templates/lupine-template-fullstack-starter/web/src/pages/page2-page.tsx +38 -0
  87. package/templates/lupine-template-fullstack-starter/web/src/pages/user-favorite-page.tsx +58 -0
  88. package/templates/lupine-template-fullstack-starter/web/src/pages/user-home-page.tsx +27 -0
  89. package/templates/lupine-template-fullstack-starter/web/src/pages/user-mine-page.tsx +54 -0
  90. package/templates/lupine-template-fullstack-starter/web/src/pages/user-profile-page-zh.tsx +112 -0
  91. package/templates/lupine-template-fullstack-starter/web/src/pages/user-profile-page.tsx +112 -0
  92. package/templates/lupine-template-fullstack-starter/web/src/pages/user1-page.tsx +57 -0
  93. package/templates/lupine-template-fullstack-starter/web/src/services/fetch-data.ts +55 -0
  94. package/templates/lupine-template-fullstack-starter/web/src/services/shared-data.ts +19 -0
  95. package/templates/lupine-template-fullstack-starter/web/src/styles/base-css.ts +17 -0
  96. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/global.css +10 -57
  97. package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/theme.ts +3 -1
  98. package/templates/lupine-template-responsive-starter/README.md +7 -0
  99. package/templates/lupine-template-responsive-starter/web/src/components/input-history-component.tsx +1 -1
  100. package/templates/lupine-template-responsive-starter/web/src/components/mine-about-page.tsx +2 -1
  101. package/templates/lupine-template-responsive-starter/web/src/components/mine-premium-page.tsx +2 -1
  102. package/templates/lupine-template-responsive-starter/web/src/components/mine-settings-page.tsx +8 -17
  103. package/templates/lupine-template-responsive-starter/web/src/components/mobile-top-search-menu.tsx +15 -27
  104. package/templates/lupine-template-responsive-starter/web/src/components/note-detail.tsx +2 -8
  105. package/templates/lupine-template-responsive-starter/web/src/components/note-edit.tsx +26 -36
  106. package/templates/lupine-template-responsive-starter/web/src/components/note-search-page.tsx +16 -21
  107. package/templates/lupine-template-responsive-starter/web/src/components/search-input.tsx +9 -9
  108. package/templates/lupine-template-responsive-starter/web/src/components/side-menu-content.tsx +3 -16
  109. package/templates/lupine-template-responsive-starter/web/src/frames/app-responsive-frame.tsx +3 -2
  110. package/templates/lupine-template-responsive-starter/web/src/index.tsx +2 -11
  111. package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.tsx +1 -10
  112. package/templates/lupine-template-responsive-starter/web/src/pages/about-page.tsx +3 -14
  113. package/templates/lupine-template-responsive-starter/web/src/pages/finance-page.tsx +3 -14
  114. package/templates/lupine-template-responsive-starter/web/src/pages/home-page.tsx +7 -15
  115. package/templates/lupine-template-responsive-starter/web/src/pages/mine-page.tsx +7 -14
  116. package/templates/lupine-template-responsive-starter/web/src/pages/tools-page.tsx +3 -14
  117. package/templates/lupine-template-responsive-starter/web/src/styles/theme.ts +2 -1
  118. package/templates/common/AI_CONTEXT.md +0 -1002
  119. package/templates/lupine-template-hello-world/api/package.json +0 -6
  120. package/templates/lupine-template-hello-world/api/resources/install.sqlite.sql +0 -4
  121. package/templates/lupine-template-hello-world/api/src/service/root-api.ts +0 -18
  122. package/templates/lupine-template-hello-world/web/src/index.tsx +0 -73
  123. package/templates/lupine-template-hello-world/web/src/styles/base-css.ts +0 -1
  124. /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/api/resources/config_default.json +0 -0
  125. /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/api/src/index.ts +0 -0
  126. /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/assets/favicon.ico +0 -0
  127. /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/app.css +0 -0
@@ -0,0 +1,54 @@
1
+ # Router, SSR and settings (web)
2
+
3
+ Documentation: https://uuware.github.io/lupine.js/en/essentials/page-route, https://uuware.github.io/lupine.js/en/essentials/ssr.
4
+
5
+ ## PageRouter
6
+
7
+ ```tsx
8
+ import { bindRouter, PageProps, PageRouter } from 'lupine.web';
9
+
10
+ const HomePage = async () => <h1>Home</h1>;
11
+ const PlayPage = async (props: PageProps) => <p>{props.urlParameters['id']} {props.query['tab']}</p>;
12
+ const NotFoundPage = async () => <h1>404</h1>;
13
+
14
+ const pageRouter = new PageRouter();
15
+ pageRouter.use('/', HomePage);
16
+ pageRouter.use('/play/:id', PlayPage);
17
+ pageRouter.use('*', NotFoundPage); // last
18
+ bindRouter(pageRouter); // in index.tsx
19
+ ```
20
+
21
+ - Routes are tried in order; `/about` also matches `/about/...`, so specific paths come first.
22
+ - `/:id` required, `/?id` optional (and everything after it); the first parameter of a path is a `/:` one; fixed segments may follow (`/page/:id/detail`).
23
+ - A page gets `PageProps`: `url`, `query`, `urlParameters`, `renderPageFunctions`. It may be async; `null` passes to the next route.
24
+ - Nested routers: `pageRouter.use('/user', userRouter)`. Filters: `userRouter.setFilter(checkAuth)` or `use(path, checkAuth, Page)`; a filter returns a node to show instead, or `null`. They only decide what is shown: the API checks access to data.
25
+ - Layout: `pageRouter.setFramePage({ component: MainFrame, placeholderClassname: 'app-content' })`; only the placeholder is replaced, the frame keeps its state.
26
+ - `setErrorHandler`, `setSubDir('/my-app')` for a site in a subfolder.
27
+
28
+ ## Going to a page
29
+
30
+ Links inside the site are `<a href='/play/1'>` and don't reload the page. From code:
31
+
32
+ ```tsx
33
+ import { initializePage } from 'lupine.web';
34
+
35
+ const Next = () => <button onClick={() => initializePage('/play/2')}>Next</button>;
36
+ ```
37
+
38
+ Not `location.href = ...` (that reloads everything).
39
+
40
+ ## SSR
41
+
42
+ For every URL that isn't an API or a file the server runs the router and sends complete HTML (with theme, styles, title and meta tags). The browser then renders the same route again and **replaces** the content; there is no hydration.
43
+
44
+ - Data that belongs in the HTML: load it in the async page with `props.renderPageFunctions.fetchData(url)` (on the server it calls the API inside the process, with the request's cookies). Title and meta: `PageTitle`, `MetaData` of `lupine.web.components`.
45
+ - Only the browser: `localStorage`, window sizes, `document`, data of the signed-in user. Put it in `onMount`, or check `isFrontEnd()`. Code that runs while rendering must not touch them.
46
+ - `createEffect` and `onMount` don't run on the server; signals are read once.
47
+ - Module variables and signals are shared by all users on the server.
48
+ - Styles at the top of a module: `bindAppGlobalStyle`; `bindGlobalStyle` belongs inside a component (references/styling-and-themes.md).
49
+ - Where there are no props: `getRenderPageProps()` gives `url` and `query`.
50
+
51
+ ## Settings
52
+
53
+ - `.env` variables that start with `WEB.` reach the front end: `webEnv('API_BASE_URL', '')` (synchronous; the type follows the default). All others stay on the server.
54
+ - Settings that change without a release: `await WebConfig.get('siteLogo', '')`. The server puts them into the first page; written by the back end (`apiStorage.setWeb`).
@@ -0,0 +1,108 @@
1
+ # Signals and state
2
+
3
+ The same signals on the web and in native apps. Import them from `lupine.web` (web) or `lupine.native.core` (native); both pass on `lupine.core`. Documentation: https://uuware.github.io/lupine.js/en/essentials/signals, https://uuware.github.io/lupine.js/en/essentials/list, https://uuware.github.io/lupine.js/en/essentials/forms.
4
+
5
+ ## A component
6
+
7
+ ```tsx
8
+ import { createEffect, createMemo, createSignal, CssProps, onCleanup } from 'lupine.web';
9
+
10
+ export const Score = () => {
11
+ const [score, setScore] = createSignal(0);
12
+ const label = createMemo(() => (score() > 9 ? 'high' : 'low'));
13
+
14
+ createEffect(() => {
15
+ // after the component is in the page, and whenever score changes
16
+ const timer = setTimeout(() => setScore(0), 5000);
17
+ onCleanup(() => clearTimeout(timer));
18
+ });
19
+
20
+ const css: CssProps = {
21
+ '.&-score': { fontSize: '18px', fontWeight: 'bold' },
22
+ '.&-score.high': { color: 'var(--primary-accent-color)' },
23
+ };
24
+
25
+ return (
26
+ <div css={css}>
27
+ <div class={() => `&-score ${label()}`}>Score: {score}</div>
28
+ <button onClick={() => setScore((s) => s + 1)}>Add</button>
29
+ <button disabled={() => score() === 0} onClick={() => setScore(0)}>Reset</button>
30
+ {() => (score() > 20 ? <p>Well done</p> : null)}
31
+ </div>
32
+ );
33
+ };
34
+ ```
35
+
36
+ - The function runs **once**. Only the places that read a signal are updated; focus, caret, scroll position and the state of children are kept.
37
+ - Pass a function: `{score}` and `{() => score() + 1}` are updated, `{score()}` is read once. The same for attributes, props and style values.
38
+ - A write is visible to reads at once; the page follows in the next microtask. `flush()` updates it now (tests, measuring).
39
+ - `untrack(fn)` reads without subscribing. `batch` isn't needed: writes of one event are one update.
40
+
41
+ ## Lifecycle
42
+
43
+ | | |
44
+ | --- | --- |
45
+ | `createMemo(fn)` | a derived value, computed when its signals change |
46
+ | `createEffect(fn)` | runs after mounting and again when what it read changes; not on the server |
47
+ | `onMount(fn)` | once, when the component is shown; not on the server |
48
+ | `onCleanup(fn)` | when the component (or the effect) is removed |
49
+
50
+ In an **async component** call them before the first `await`; after it there is no owner.
51
+
52
+ ## Global state
53
+
54
+ A signal at the top of a module is shared by everything that imports it:
55
+
56
+ ```ts
57
+ import { createSignal } from 'lupine.web';
58
+
59
+ export const [cartCount, setCartCount] = createSignal(0);
60
+ ```
61
+
62
+ On a web server such a module is shared by **all users**: nothing of one user goes there (load it in the browser, in `onMount`).
63
+
64
+ ## Elements (web)
65
+
66
+ ```tsx
67
+ import { onMount } from 'lupine.web';
68
+
69
+ const Search = () => {
70
+ let input: HTMLInputElement;
71
+ onMount(() => input.focus());
72
+ return <input ref={(el) => (input = el)} />;
73
+ };
74
+ ```
75
+
76
+ `ref` is called before `onMount`. Use it for focus, measuring, canvases and libraries; never `document.querySelector` to find your own elements (class names with `&` are generated). In native apps `ref` gives a handle with `focus()`, `measure()`, `scrollTo()`.
77
+
78
+ ## Lists and conditions
79
+
80
+ ```tsx
81
+ import { createSignal, For, onMount, Show } from 'lupine.web';
82
+ import { createField } from 'lupine.web.components';
83
+
84
+ const ItemsPage = () => {
85
+ const query = createField('');
86
+ const [items, setItems] = createSignal<Item[] | null>(null);
87
+ const load = async () => setItems(await fetchItems(query()));
88
+ onMount(() => void load());
89
+
90
+ return (
91
+ <div>
92
+ <input {...query.input} />
93
+ <button onClick={load}>Search</button>
94
+ <Show when={() => items() !== null} fallback={<div>Loading...</div>}>
95
+ <For each={() => items()!}>{(item) => <ItemRow item={item} />}</For>
96
+ </Show>
97
+ </div>
98
+ );
99
+ };
100
+ ```
101
+
102
+ - `For` keeps a row as long as its item (the same object) is in the array. Update with a new array that keeps the unchanged objects: `setItems(items().map((x) => (x.id === id ? { ...x, done: true } : x)))`.
103
+ - What changes inside a row is best a signal of its own, or that one object is replaced.
104
+ - Hundreds of rows on the web: page them; in native apps use `List` / `VirtualList`.
105
+
106
+ ## Forms (web)
107
+
108
+ `createField(initial)` of `lupine.web.components` is a signal for a form element: `<input {...title.input} />`, `<input type='checkbox' {...on.check} />`, read `title()`, write `title.set('x')`. Native apps: `TextInput value={v} onChangeText={setV}` or `createForm` of `lupine.native.components`.
@@ -0,0 +1,119 @@
1
+ # Styling & Themes
2
+
3
+ ## 1. Style Binding & Ampersand (`&`) Namespace Pattern
4
+
5
+ Lupine.js uses CSS-in-JS and achieves component style isolation by dynamically generating unique class name prefixes (e.g. `l1234`) and replacing the `&` symbol.
6
+
7
+ ```tsx
8
+ import { createSignal, CssProps } from 'lupine.web';
9
+
10
+ export const MyComponent = () => {
11
+ const [active, setActive] = createSignal(false);
12
+ const css: CssProps = {
13
+ // Top-level rules apply directly to the bound root container itself
14
+ width: '100%',
15
+ padding: '1rem',
16
+
17
+ // Rules targeting descendant elements
18
+ '.&-title': { fontWeight: 'bold' },
19
+ '.&-btn': {
20
+ '&:hover': { background: 'var(--secondary-bg-color)' },
21
+ '&.active': { color: 'var(--primary-accent-color)' },
22
+ },
23
+ };
24
+
25
+ return (
26
+ <aside css={css}>
27
+ <div class='&-title'>Hello</div>
28
+ <button class={() => (active() ? '&-btn active' : '&-btn')} onClick={() => setActive(!active())}>
29
+ Click Me
30
+ </button>
31
+ </aside>
32
+ );
33
+ };
34
+ ```
35
+
36
+ ### Key Rules
37
+ 1. **Top-Level Properties Apply to Root Element**: Do not wrap root styles in an unnecessary outer `.&-container` in `CssProps`.
38
+ 2. **JSX Class Names**: Use `class="&-item"` or `class="row-box &-item"` (never write `className`).
39
+ 3. **No DOM Queries**: `querySelector('.&-item')` finds nothing. What changes is a signal; an element you need has a `ref={(el) => ...}`.
40
+
41
+ ---
42
+
43
+ ## 2. Dark Mode & Color Variable Conventions (Dark Mode Semantics)
44
+
45
+ **Never hardcode color values (such as `#000`, `#fff`, `#f0f0f0`)**. Always use standardized CSS variables:
46
+
47
+ 1. **Background Colors**:
48
+ - `var(--primary-bg-color)`: Deepest background (white in light mode, **pure black** in dark mode).
49
+ - `var(--secondary-bg-color)`: Elevated cards/panels/modal backgrounds (light gray in light mode, **dark gray** in dark mode to prevent blending into pure black backgrounds).
50
+ 2. **Text Colors**:
51
+ - `var(--primary-color)`: Primary text color (dark gray/black in light mode, **white** in dark mode).
52
+ - ⚠️ **Dark Mode Trap**: Never use `--primary-color` as the background color for a blue primary button; otherwise, the button background turns white in dark mode.
53
+ 3. **Brand & Action Highlights**:
54
+ - `var(--primary-accent-color)`: Primary brand color (e.g. Lupine blue), used for primary button backgrounds, active tabs, etc.
55
+ - Pair primary button text with `var(--primary-bg-color)` to ensure high contrast.
56
+ 4. **Borders & Spacing**:
57
+ - Borders: `var(--primary-border)`, `var(--secondary-border-color)`
58
+ - Spacing: `var(--space-m)` (8px), `var(--space-l)` (16px)
59
+
60
+ ---
61
+
62
+ ## 3. CSS Scope Reuse
63
+
64
+ ### Sharing Styles Across Component Instances (Module Level)
65
+ When rendering many identical components (such as list items), avoid injecting duplicate `<style>` tags by using `bindGlobalStyle`:
66
+
67
+ ```tsx
68
+ import { bindGlobalStyle, CssProps, getGlobalStylesId } from 'lupine.web';
69
+
70
+ const cssShared: CssProps = {
71
+ display: 'flex',
72
+ '.&-content': { color: 'red' },
73
+ };
74
+
75
+ export const ListItem = () => {
76
+ const globalCssId = getGlobalStylesId(cssShared);
77
+ bindGlobalStyle(globalCssId, cssShared);
78
+
79
+ return (
80
+ <div css={globalCssId}>
81
+ <div class='&-content'>Shared CSS</div>
82
+ </div>
83
+ );
84
+ };
85
+ ```
86
+
87
+ The element gets the id as a class, and `&` in class names here and below stands for it. `css={[globalCssId, props.style]}` adds styles of this element, which win.
88
+
89
+ ### Application-Level Global Styles
90
+ At the top of a module, or once in `index.tsx`, use `bindAppGlobalStyle`. It is shared by all pages and, on the server, by all requests; `bindGlobalStyle` belongs inside a component (it is per request in SSR). The 4th parameter `noTopClassName = true` writes the rules without a class in front (for `body`, `html`, `[data-theme]`):
91
+ ```tsx
92
+ import { bindAppGlobalStyle, CssProps } from 'lupine.web';
93
+
94
+ const appSharedCss: CssProps = {
95
+ body: { margin: 0, fontFamily: 'var(--font-family-base)' },
96
+ '.app-card': { padding: 'var(--space-l)', borderRadius: '8px' },
97
+ };
98
+ bindAppGlobalStyle('app-shared-css', appSharedCss, false, true);
99
+ ```
100
+
101
+ ---
102
+
103
+ ## 4. Themes
104
+
105
+ ```tsx
106
+ import { bindTheme, getCurrentTheme, updateTheme } from 'lupine.web';
107
+ import { darkThemes, lightThemes } from 'lupine.web.components';
108
+
109
+ bindTheme('light', {
110
+ light: { ...lightThemes, '--primary-accent-color': '#0a8f2a' },
111
+ dark: { ...darkThemes, '--primary-accent-color': '#0ac92a' },
112
+ }); // index.tsx
113
+
114
+ const Toggle = () => (
115
+ <button onClick={() => updateTheme(getCurrentTheme().themeName === 'dark' ? 'light' : 'dark')}>Theme</button>
116
+ );
117
+ ```
118
+
119
+ A theme is a set of CSS variables; components that use variables only need no change when it switches. The name is kept in a cookie, so the server renders the right theme from the first byte. Code that draws (canvas) listens to `updateThemeEventName` on `window`, in `onMount`.
@@ -3,8 +3,8 @@ WEB.API_PORT=11080
3
3
  WEB.API_BASE_URL=
4
4
 
5
5
  # start with “app_name.” will be assigned to the individual app's env object
6
- # demo.app.WEB.test2=11aa
7
- # demo.app.test2=11aa
6
+ # demo.WEB.test2=11aa
7
+ # demo.test2=11aa
8
8
 
9
9
  # used by Server Side Renderring for fetch (can't be localhost)
10
10
  API_BASE_URL=http://127.0.0.1:11080
@@ -31,14 +31,24 @@ LOG_OUT_TO_CONSOLE=true
31
31
  # server path for web (appName_web), server (server) and data (appName_data)
32
32
  SERVER_ROOT_PATH=dist/server_root
33
33
  ADMIN_USER=admin
34
+ # ADMIN_PASS and DEV_ADMIN_PASS use layered salted scrypt ("scrypt2$<saltHex>$<sha256(scryptKeyHex)>"):
35
+ # node -e 'const pwd="YOUR PASSWORD",c=require("crypto"),s=c.randomBytes(16).toString("hex"),k=c.scryptSync(pwd,Buffer.from(s,"hex"),32,{N:16384,r:8,p:1,maxmem:64*1024*1024}).toString("hex");console.log(`scrypt2$${s}$${c.createHash("sha256").update(k).digest("hex")}`)'
34
36
  ADMIN_PASS=
35
37
  CRYPTO_KEY=
38
+ # Admin session expiration in days (default: 90)
39
+ # ADMIN_SESSION_EXPIRE_DAYS=90
36
40
 
37
41
  # for development
38
42
  DEV_ADMIN_USER=admin
39
43
  DEV_ADMIN_PASS=
40
44
  DEV_CRYPTO_KEY=
41
45
  DEV_TOKEN=
46
+ # Dev-admin session expiration in days (default: 90)
47
+ # DEV_ADMIN_SESSION_EXPIRE_DAYS=90
48
+ # Set DEV_ENABLE_SHELL=true only when remote shell debugging is explicitly needed
49
+ # DEV_ENABLE_SHELL=false
50
+ # Set DEV_ENABLE_FILES=true to let Files of the dev admin also show the built server and the project folder with .env files
51
+ # DEV_ENABLE_FILES=false
42
52
 
43
53
  # define apps on the same port with different domains (locally or on a real server)
44
54
  # in local, the domains should be added to the /etc/hosts (or C:\Windows\System32\drivers\etc\hosts) file
@@ -56,10 +56,11 @@ const initAndStartServer = async () => {
56
56
  const sslKeyPath = process.env[ServerEnvKeys.SSL_KEY_PATH] || '';
57
57
  const sslCrtPath = process.env[ServerEnvKeys.SSL_CRT_PATH] || '';
58
58
 
59
+ const rawDevToken = process.env['DEV_TOKEN'] || '';
59
60
  // Can't use log until initApp is called (after AppStart.start)
60
61
  await appStart.start({
61
62
  debug: process.env[ServerEnvKeys.NODE_ENV] === 'development',
62
- devToken: CryptoUtils.sha256(process.env['DEV_TOKEN'] || ''),
63
+ devToken: rawDevToken ? CryptoUtils.sha256(rawDevToken) : '',
63
64
  appEnvFile: envFile,
64
65
  apiConfig: {
65
66
  serverRoot: `${serverRootPath}`,
@@ -0,0 +1,5 @@
1
+ # CV Starter
2
+
3
+ A CV as a web site, written in Markdown (`web/markdown`), with lupine.press: several languages, light and dark themes, and it can be published to GitHub Pages. A template of `npx create-lupine` (`cv-starter`).
4
+
5
+ [Live demo](https://uuware.github.io/lupine-template-cv-starter/) · [Repository](https://github.com/uuware/lupine-template-cv-starter)
@@ -1,13 +1,4 @@
1
- import {
2
- bindRouter,
3
- PageRouter,
4
- bindTheme,
5
- setDefaultPageTitle,
6
- isFrontEnd,
7
- debugWatch,
8
- webEnv,
9
- bindAppGlobalStyle,
10
- } from 'lupine.components';
1
+ import { bindRouter, PageRouter, bindTheme, setDefaultPageTitle, isFrontEnd, debugWatch, webEnv, bindAppGlobalStyle } from 'lupine.web';
11
2
  import { bindPressData, PressPage, pressThemes } from 'lupine.press';
12
3
  import { markdownConfig } from './markdown-built/markdown-config';
13
4
  import { ClientEnvKeys } from './client-env-keys';
@@ -1,13 +1,4 @@
1
- import {
2
- bindRouter,
3
- PageRouter,
4
- bindTheme,
5
- setDefaultPageTitle,
6
- isFrontEnd,
7
- debugWatch,
8
- webEnv,
9
- bindAppGlobalStyle,
10
- } from 'lupine.components';
1
+ import { bindRouter, PageRouter, bindTheme, setDefaultPageTitle, isFrontEnd, debugWatch, webEnv, bindAppGlobalStyle } from 'lupine.web';
11
2
  import { bindPressData, PressPage, pressThemes, setPressSubDir } from 'lupine.press';
12
3
  import { ClientEnvKeys } from '../client-env-keys';
13
4
  import { baseCss } from '../styles/base-css';
@@ -0,0 +1,5 @@
1
+ # Doc Starter
2
+
3
+ A documentation site from Markdown files with lupine.press: a sidebar from the folders, several languages (`web/markdown/en`, `web/markdown/zh`), light and dark themes, search engines see the pages (SSR), and it can be published to GitHub Pages. A template of `npx create-lupine` (`doc-starter`).
4
+
5
+ [Live demo](https://uuware.github.io/lupine-template-doc-starter/) · [Repository](https://github.com/uuware/lupine-template-doc-starter)
@@ -1,13 +1,4 @@
1
- import {
2
- bindRouter,
3
- PageRouter,
4
- bindTheme,
5
- setDefaultPageTitle,
6
- isFrontEnd,
7
- debugWatch,
8
- webEnv,
9
- bindAppGlobalStyle,
10
- } from 'lupine.components';
1
+ import { bindRouter, PageRouter, bindTheme, setDefaultPageTitle, isFrontEnd, debugWatch, webEnv, bindAppGlobalStyle } from 'lupine.web';
11
2
  import { bindPressData, PressPage, pressThemes } from 'lupine.press';
12
3
  import { markdownConfig } from './markdown-built/markdown-config';
13
4
  import { ClientEnvKeys } from './client-env-keys';
@@ -1,13 +1,4 @@
1
- import {
2
- bindRouter,
3
- PageRouter,
4
- bindTheme,
5
- setDefaultPageTitle,
6
- isFrontEnd,
7
- debugWatch,
8
- webEnv,
9
- bindAppGlobalStyle,
10
- } from 'lupine.components';
1
+ import { bindRouter, PageRouter, bindTheme, setDefaultPageTitle, isFrontEnd, debugWatch, webEnv, bindAppGlobalStyle } from 'lupine.web';
11
2
  import { bindPressData, PressPage, pressThemes, setPressSubDir } from 'lupine.press';
12
3
  import { ClientEnvKeys } from '../client-env-keys';
13
4
  import { baseCss } from '../styles/base-css';
@@ -0,0 +1,21 @@
1
+ # Full-stack Web Starter
2
+
3
+ A web site with lupine.web and lupine.api: pages rendered on the server (SSR) and updated in the browser, nested page frames, sign-in, an admin area and an API with a database. For an app that looks like a phone app see `lupine-template-responsive-starter`; for native apps `apps/native-starter`.
4
+
5
+ | Part | Where |
6
+ | --- | --- |
7
+ | pages, frames, the router | `web/src/index.tsx`, `web/src/pages`, `web/src/frames` |
8
+ | sign-in, registration, codes by email, new password | `web/src/components/login*.tsx`, `register.tsx`, `reset-password.tsx`; `api/src/service/user-api.ts` |
9
+ | users' pages (need a sign-in) | `/user/mine`, `/user/favorite`, `/user/profile`, `/user/contact` |
10
+ | admin area (admins only) | `/admin`: users, settings, items; `api/src/service/admin-api.ts` |
11
+ | tools of the developer | `/admin_dev` (database, logs, settings; `DEV_ADMIN_USER` / `DEV_ADMIN_PASS`) |
12
+ | the components of lupine.web.components | `/demo` |
13
+ | API routes | `api/src/service/api.ts` |
14
+
15
+ ## First start
16
+
17
+ 1. In `.env`: `CRYPTO_KEY`, `ADMIN_USER` / `ADMIN_PASS`, `DEV_ADMIN_USER` / `DEV_ADMIN_PASS` (create-lupine fills in random ones), and for mail `SEND_EMAIL_USER` / `SEND_EMAIL_PASS`.
18
+ 2. `npm run dev`, then open `/admin_dev` and create the tables from `api/resources/install.sqlite.sql` (or `install.mysql.sql`).
19
+ 3. The contact form sends to the address `siteEmail` of the settings (`/admin`, settings).
20
+
21
+ Writing routes are POST only and check the session; uploads check the type and the size; codes by email can be asked for once a minute and don't tell whether an address has an account; the contact form takes five messages an hour from an address (per worker process: limit it in front of the server, too).
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "lupine-template-fullstack-starter-api",
3
+ "version": "1.0.0",
4
+ "dependencies": {
5
+ "nodemailer": "^6.9.16"
6
+ },
7
+ "devDependencies": {
8
+ "@types/nodemailer": "^6.4.17"
9
+ }
10
+ }
@@ -0,0 +1,107 @@
1
+ #-- Auto Created for MySQL / MariaDB
2
+ #-- Never name a table with plural (such as "users")
3
+ #-- Never name a table using a reserved keyword (such as "user")
4
+ #-- Never prefix your table name with "tbl" or some other object type prefix
5
+
6
+ CREATE TABLE IF NOT EXISTS $__s_page (
7
+ pageid VARCHAR(50) NOT NULL,
8
+ name VARCHAR(100) NOT NULL DEFAULT '',
9
+ is_component INTEGER NOT NULL DEFAULT 0,
10
+ remark VARCHAR(250) NOT NULL DEFAULT '',
11
+ package VARCHAR(20) NOT NULL DEFAULT '',
12
+ accesslevel CHAR(1) NOT NULL DEFAULT '0',
13
+ json TEXT NOT NULL,
14
+ updateduserid INTEGER,
15
+ updatetime BIGINT NOT NULL DEFAULT 0,
16
+ PRIMARY KEY (pageid)
17
+ );
18
+
19
+ CREATE TABLE IF NOT EXISTS $__s_menu (
20
+ menuid VARCHAR(50) NOT NULL,
21
+ name VARCHAR(100) NOT NULL DEFAULT '',
22
+ remark VARCHAR(250) NOT NULL DEFAULT '',
23
+ package VARCHAR(20) NOT NULL DEFAULT '',
24
+ accesslevel CHAR(1) NOT NULL DEFAULT '0',
25
+ json TEXT NOT NULL,
26
+ updateduserid INTEGER,
27
+ updatetime BIGINT NOT NULL DEFAULT 0,
28
+ PRIMARY KEY (menuid)
29
+ );
30
+
31
+ CREATE TABLE IF NOT EXISTS $__s_process (
32
+ processid VARCHAR(50) NOT NULL,
33
+ name VARCHAR(100) NOT NULL DEFAULT '',
34
+ accesslevel CHAR(1) NOT NULL DEFAULT '0',
35
+ json TEXT NOT NULL,
36
+ package VARCHAR(20) NOT NULL DEFAULT '',
37
+ remark VARCHAR(250) NOT NULL DEFAULT '',
38
+ updatetime BIGINT NOT NULL DEFAULT 0,
39
+ PRIMARY KEY (processid)
40
+ );
41
+
42
+ CREATE TABLE IF NOT EXISTS $__s_user (
43
+ id INTEGER NOT NULL AUTO_INCREMENT,
44
+ gid INTEGER NOT NULL DEFAULT 1,
45
+ level INTEGER NOT NULL DEFAULT 0,
46
+ nickname VARCHAR(200) NOT NULL DEFAULT '',
47
+ username VARCHAR(150) NOT NULL DEFAULT '',
48
+ email VARCHAR(100) NOT NULL DEFAULT '',
49
+ password VARCHAR(100) NOT NULL DEFAULT '',
50
+ usertype VARCHAR(25) NOT NULL DEFAULT '',
51
+ block CHAR(1) NOT NULL DEFAULT '0',
52
+ sendemail CHAR(1) DEFAULT '0',
53
+ gender VARCHAR(10) DEFAULT '0',
54
+ age INTEGER NOT NULL DEFAULT 0,
55
+ training INTEGER NOT NULL DEFAULT 0,
56
+ preference VARCHAR(100) NOT NULL DEFAULT '',
57
+ registerdate VARCHAR(20) NOT NULL DEFAULT '',
58
+ lastvisitdate VARCHAR(20) NOT NULL DEFAULT '',
59
+ activated CHAR(1) NOT NULL DEFAULT '0',
60
+ activation VARCHAR(10) NOT NULL DEFAULT '',
61
+ points INTEGER NOT NULL DEFAULT 0,
62
+ pwtips VARCHAR(100) DEFAULT '',
63
+ pwretry INTEGER NOT NULL DEFAULT 0,
64
+ pwquestion VARCHAR(100) DEFAULT '',
65
+ pwanswer VARCHAR(100) DEFAULT '',
66
+ PRIMARY KEY (id)
67
+ );
68
+
69
+ #-- TABLE:$__st_calendar
70
+ CREATE TABLE IF NOT EXISTS $__s_calendar (
71
+ calendarid VARCHAR(50) NOT NULL,
72
+ title VARCHAR(250) NOT NULL DEFAULT '',
73
+ published CHAR(1) NOT NULL DEFAULT '0',
74
+ remark VARCHAR(250),
75
+ monthfrom VARCHAR(6),
76
+ monthto VARCHAR(6),
77
+ bkcolor VARCHAR(7),
78
+ cidstring VARCHAR(50) NOT NULL DEFAULT '',
79
+ PRIMARY KEY (calendarid)
80
+ );
81
+
82
+ CREATE TABLE IF NOT EXISTS $__s_user_right (
83
+ username VARCHAR(150) NOT NULL,
84
+ rightsid VARCHAR(50) NOT NULL,
85
+ rightsgroup VARCHAR(10) NOT NULL DEFAULT '',
86
+ value TEXT NOT NULL,
87
+ PRIMARY KEY (username, rightsid)
88
+ );
89
+
90
+ CREATE TABLE IF NOT EXISTS $__image_folder (
91
+ id INTEGER NOT NULL AUTO_INCREMENT,
92
+ folder_id VARCHAR(10) NOT NULL DEFAULT '',
93
+ display_name VARCHAR(50) NOT NULL DEFAULT '',
94
+ parent_full_path VARCHAR(255) NOT NULL DEFAULT '',
95
+ full_path VARCHAR(255) NOT NULL DEFAULT '',
96
+ PRIMARY KEY (id)
97
+ );
98
+
99
+ CREATE TABLE IF NOT EXISTS $__image (
100
+ id INTEGER NOT NULL AUTO_INCREMENT,
101
+ file_id VARCHAR(20) NOT NULL DEFAULT '',
102
+ display_name VARCHAR(50) NOT NULL DEFAULT '',
103
+ parent_full_path VARCHAR(255) NOT NULL DEFAULT '',
104
+ version INTEGER NOT NULL DEFAULT 0,
105
+ updatetime BIGINT NOT NULL DEFAULT 0,
106
+ PRIMARY KEY (id)
107
+ );
@@ -0,0 +1,75 @@
1
+ #-- Auto Created By WebNoCoding at:2015-06-03 16:51:43
2
+ #-- Never name a table with plural (such as "users")
3
+ #-- Never name a table using a reserved keyword (such as "user")
4
+ #-- Never prefix your table name with "tbl" or some other object type prefix
5
+
6
+ CREATE TABLE $__s_page (
7
+ pageid VARCHAR(50) NOT NULL,
8
+ title VARCHAR(100) NOT NULL DEFAULT '',
9
+ note VARCHAR(250) NOT NULL DEFAULT '',
10
+ package VARCHAR(20) NOT NULL DEFAULT '',
11
+ items TEXT NOT NULL DEFAULT '',
12
+ updateduserid INTEGER,
13
+ updatedstamp VARCHAR(20),
14
+ PRIMARY KEY (pageid)
15
+ );
16
+
17
+ CREATE TABLE $__s_menu (
18
+ menuid VARCHAR(50) NOT NULL,
19
+ title VARCHAR(100) NOT NULL DEFAULT '',
20
+ note VARCHAR(250) NOT NULL DEFAULT '',
21
+ package VARCHAR(20) NOT NULL DEFAULT '',
22
+ items TEXT NOT NULL DEFAULT '',
23
+ updateduserid INTEGER,
24
+ updatedstamp VARCHAR(20),
25
+ PRIMARY KEY (menuid)
26
+ );
27
+
28
+ CREATE TABLE $__s_user (
29
+ id INTEGER NOT NULL DEFAULT '0',
30
+ gid INTEGER NOT NULL DEFAULT '1',
31
+ level INTEGER NOT NULL DEFAULT '0',
32
+ nickname VARCHAR(200) NOT NULL DEFAULT '',
33
+ username VARCHAR(150) NOT NULL DEFAULT '',
34
+ email VARCHAR(100) NOT NULL DEFAULT '',
35
+ password VARCHAR(100) NOT NULL DEFAULT '',
36
+ usertype VARCHAR(25) NOT NULL DEFAULT '',
37
+ block CHAR(1) NOT NULL DEFAULT '0',
38
+ sendemail CHAR(1) DEFAULT '0',
39
+ gender VARCHAR(10) DEFAULT '0',
40
+ age INTEGER NOT NULL DEFAULT '0',
41
+ training INTEGER NOT NULL DEFAULT '0',
42
+ preference VARCHAR(100) NOT NULL DEFAULT '',
43
+ registerdate VARCHAR(20) NOT NULL DEFAULT '',
44
+ lastvisitdate VARCHAR(20) NOT NULL DEFAULT '',
45
+ activated CHAR(1) NOT NULL DEFAULT '0',
46
+ activation VARCHAR(10) NOT NULL DEFAULT '',
47
+ points INTEGER NOT NULL DEFAULT '0',
48
+ pwtips VARCHAR(100) DEFAULT '',
49
+ pwretry INTEGER NOT NULL DEFAULT '0',
50
+ pwquestion VARCHAR(100) DEFAULT '',
51
+ pwanswer VARCHAR(100) DEFAULT '',
52
+ PRIMARY KEY (id)
53
+ );
54
+
55
+ #-- TABLE:$__st_calendar
56
+ CREATE TABLE $__s_calendar (
57
+ calendarid VARCHAR(50) NOT NULL,
58
+ title VARCHAR(250) NOT NULL DEFAULT '',
59
+ published CHAR(1) NOT NULL DEFAULT '0',
60
+ remark VARCHAR(250),
61
+ monthfrom VARCHAR(6),
62
+ monthto VARCHAR(6),
63
+ bkcolor VARCHAR(7),
64
+ cidstring VARCHAR(50) NOT NULL DEFAULT '',
65
+ PRIMARY KEY (calendarid)
66
+ );
67
+
68
+ CREATE TABLE $__s_user_right (
69
+ username VARCHAR(150) NOT NULL,
70
+ rightsid VARCHAR(50) NOT NULL,
71
+ rightsgroup VARCHAR(10) NOT NULL DEFAULT '',
72
+ value TEXT NOT NULL,
73
+ PRIMARY KEY (username, rightsid)
74
+ );
75
+
@@ -0,0 +1,39 @@
1
+ import { OneLangProps } from 'lupine.api';
2
+
3
+ export const apiLangEn: OneLangProps = {
4
+ langName: 'en',
5
+ langs: {
6
+ 'shared:process_completed': 'Process completed',
7
+ 'shared:process_failed': 'Process failed',
8
+ 'shared:wrong_parameters': 'Wrong parameters.',
9
+ 'shared:record_not_found': 'Record not found.',
10
+ 'shared:record_not_updated': 'Record not updated.',
11
+ 'shared:record_updated': 'Record updated.',
12
+ 'shared:record_creation_failed': 'Record creation failed.',
13
+ 'shared:record_loaded': 'Record loaded.',
14
+ 'shared:record_deleted': 'Record deleted.',
15
+ 'shared:file_too_large': 'File is too large.',
16
+ 'shared:file_uploaded': 'You have uploaded a file.',
17
+ 'shared:file_not_found': 'File not found.',
18
+ 'shared:wrong_file_extension': 'Wrong file extension.',
19
+ 'shared:file_part_updated': 'Part file is uploaded.',
20
+ 'shared:file_update_failed': 'Failed to upload.',
21
+ 'shared:configuration_updated': 'Configuration updated.',
22
+ 'shared:user_not_activated': 'Account not activated.',
23
+ 'shared:wrong_email_format': 'Wrong email format.',
24
+ 'shared:register_failed': 'Register failed, please contact administrator.',
25
+ 'shared:register_success': 'You have successfully registered. Please login to your account.',
26
+ 'shared:send_email_notification': 'Email notification sent.',
27
+ 'shared:updated_profile': 'Profile updated.',
28
+ 'shared:password_length_wrong': 'Password length is wrong, must be at least {len} characters.',
29
+ 'shared:no_update_for_special_user': 'This is a special user, cannot update profile.',
30
+ 'shared:login_failed_too_many_times': 'Login failed too many times, please wait {minutes} minutes to retry.',
31
+ 'shared:register_username_exists':
32
+ 'This username already exists, please input a new email or reset your current account password.',
33
+ // 'shared:send_email_activation': 'Activation code sent to your email.',
34
+ 'shared:send_and_copy_activation':
35
+ 'An Email has been sent to you with the authentication code. Please copy that authentication code to login or reset your password.',
36
+ 'shared:wrong_activation': 'Wrong activation code.',
37
+ 'shared:password_reset_success': 'Password reset successfully, please login.',
38
+ },
39
+ };