create-lupine 1.2.0 → 1.3.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.
- package/README.md +13 -7
- package/index.js +232 -108
- package/package.json +1 -1
- package/templates/common/.agents/skills/lupine-framework/SKILL.md +3 -3
- package/templates/common/.agents/skills/lupine-framework/references/backend-api.md +16 -1
- package/templates/common/.agents/skills/lupine-framework/references/icon-handling.md +1 -1
- package/templates/common/.agents/skills/lupine-framework/references/mobile-interactions.md +17 -88
- package/templates/common/.agents/skills/lupine-framework/references/native-apps.md +47 -24
- package/templates/common/.agents/skills/lupine-framework/references/navigation-and-routing.md +1 -0
- package/templates/common/.agents/skills/lupine-framework/references/reactivity-and-state.md +2 -2
- package/templates/common/.agents/skills/lupine-framework/references/styling-and-themes.md +3 -1
- package/templates/common/.env.mobile +4 -3
- package/templates/common/_env +8 -4
- package/templates/common/apps/server/README.md +10 -0
- package/templates/common/dev/cp-folder.js +9 -4
- package/templates/lupine-template-cv-starter/README.md +33 -1
- package/templates/lupine-template-cv-starter/app/package.json +20 -0
- package/templates/lupine-template-cv-starter/app/src/app.tsx +6 -0
- package/templates/lupine-template-cv-starter/app/src/index.native.tsx +4 -0
- package/templates/lupine-template-cv-starter/app/src/index.test.tsx +71 -0
- package/templates/lupine-template-cv-starter/app/src/index.web.tsx +28 -0
- package/templates/lupine-template-cv-starter/app/tsconfig.json +17 -0
- package/templates/lupine-template-cv-starter/lupine.json +8 -7
- package/templates/lupine-template-cv-starter/web/src/index.html +9 -2
- package/templates/lupine-template-cv-starter/web/src/index.tsx +9 -14
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.html +9 -2
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.tsx +4 -20
- package/templates/lupine-template-doc-starter/README.md +33 -1
- package/templates/lupine-template-doc-starter/app/package.json +20 -0
- package/templates/lupine-template-doc-starter/app/src/app.tsx +6 -0
- package/templates/lupine-template-doc-starter/app/src/index.native.tsx +4 -0
- package/templates/lupine-template-doc-starter/app/src/index.test.tsx +78 -0
- package/templates/lupine-template-doc-starter/app/src/index.web.tsx +28 -0
- package/templates/lupine-template-doc-starter/app/tsconfig.json +17 -0
- package/templates/lupine-template-doc-starter/lupine.json +8 -7
- package/templates/lupine-template-doc-starter/web/src/index.html +9 -2
- package/templates/lupine-template-doc-starter/web/src/index.tsx +9 -14
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.html +9 -2
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.tsx +4 -20
- package/templates/lupine-template-fullstack-note/README.md +83 -0
- package/templates/{lupine-template-cv-starter → lupine-template-fullstack-note}/api/package.json +2 -2
- package/templates/lupine-template-fullstack-note/api/resources/install.mysql.sql +32 -0
- package/templates/lupine-template-fullstack-note/api/resources/install.sqlite.sql +27 -0
- package/templates/lupine-template-fullstack-note/api/src/service/answer.ts +39 -0
- package/templates/lupine-template-fullstack-note/api/src/service/api.ts +52 -0
- package/templates/lupine-template-fullstack-note/api/src/service/db.ts +78 -0
- package/templates/lupine-template-fullstack-note/api/src/service/notes-api.ts +86 -0
- package/templates/lupine-template-fullstack-note/api/src/service/root-api.ts +19 -0
- package/templates/lupine-template-fullstack-note/api/src/service/user-api.ts +182 -0
- package/templates/lupine-template-fullstack-note/app/package.json +19 -0
- package/templates/lupine-template-fullstack-note/app/src/app.tsx +75 -0
- package/templates/lupine-template-fullstack-note/app/src/index.native.tsx +4 -0
- package/templates/lupine-template-fullstack-note/app/src/index.test.tsx +373 -0
- package/templates/lupine-template-fullstack-note/app/src/index.web.tsx +20 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/components.tsx +65 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/details.tsx +38 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/discover.tsx +25 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/home.tsx +76 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/inbox.tsx +49 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/login.tsx +54 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/me.tsx +32 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/notes.tsx +128 -0
- package/templates/lupine-template-fullstack-note/app/src/pages/settings.tsx +45 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/AppMenu.tsx +44 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/api.ts +159 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/data.ts +20 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/locales/ja.ts +80 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/locales/zh-CN.ts +80 -0
- package/templates/lupine-template-fullstack-note/app/src/shell/texts.ts +14 -0
- package/templates/lupine-template-fullstack-note/app/tsconfig.json +17 -0
- package/templates/lupine-template-fullstack-note/lupine.json +25 -0
- package/templates/lupine-template-fullstack-note/web/assets/favicon.ico +0 -0
- package/templates/{lupine-template-doc-starter/api → lupine-template-fullstack-note/web}/package.json +2 -2
- package/templates/lupine-template-fullstack-note/web/src/index.html +23 -0
- package/templates/lupine-template-fullstack-note/web/src/index.tsx +15 -0
- package/templates/lupine-template-fullstack-starter/README.md +63 -14
- package/templates/lupine-template-fullstack-starter/api/src/service/user-api.ts +11 -6
- package/templates/lupine-template-fullstack-starter/app/package.json +20 -0
- package/templates/lupine-template-fullstack-starter/app/src/app.tsx +76 -0
- package/templates/lupine-template-fullstack-starter/app/src/index.native.tsx +4 -0
- package/templates/lupine-template-fullstack-starter/app/src/index.test.tsx +276 -0
- package/templates/lupine-template-fullstack-starter/app/src/index.web.tsx +28 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/about.tsx +27 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/contact.tsx +41 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/favorite.tsx +27 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/home.tsx +63 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/login.tsx +63 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/mine.tsx +44 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/profile.tsx +58 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/register.tsx +48 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/reset-password.tsx +41 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/settings.tsx +33 -0
- package/templates/lupine-template-fullstack-starter/app/src/pages/story.tsx +46 -0
- package/templates/lupine-template-fullstack-starter/app/src/shell/api.ts +127 -0
- package/templates/lupine-template-fullstack-starter/app/src/shell/parts.tsx +100 -0
- package/templates/lupine-template-fullstack-starter/app/src/shell/stories.ts +65 -0
- package/templates/lupine-template-fullstack-starter/app/src/shell/texts.ts +79 -0
- package/templates/lupine-template-fullstack-starter/app/tsconfig.json +17 -0
- package/templates/lupine-template-fullstack-starter/lupine.json +6 -7
- package/templates/lupine-template-fullstack-starter/web/src/admin/admin-patch.tsx +34 -0
- package/templates/lupine-template-fullstack-starter/web/src/{components → admin/components}/home-search-component.tsx +18 -25
- package/templates/lupine-template-fullstack-starter/web/src/{components → admin/components}/story-card.tsx +17 -8
- package/templates/lupine-template-fullstack-starter/web/src/{components → admin/components}/story-list.tsx +1 -2
- package/templates/lupine-template-fullstack-starter/web/src/{admin_dev → admin}/index.html +1 -0
- package/templates/lupine-template-fullstack-starter/web/src/{admin_dev → admin}/index.tsx +13 -28
- package/templates/lupine-template-fullstack-starter/web/src/{pages → admin/pages}/admin-cfg.tsx +23 -19
- package/templates/lupine-template-fullstack-starter/web/src/{pages → admin/pages}/admin-item-edit.tsx +3 -4
- package/templates/lupine-template-fullstack-starter/web/src/{pages → admin/pages}/admin-item-list.tsx +2 -3
- package/templates/lupine-template-fullstack-starter/web/src/{pages → admin/pages}/admin-user.tsx +15 -20
- package/templates/lupine-template-fullstack-starter/web/src/index.html +8 -2
- package/templates/lupine-template-fullstack-starter/web/src/index.tsx +11 -150
- package/templates/lupine-template-fullstack-starter/web/src/services/fetch-data.ts +7 -25
- package/templates/lupine-template-fullstack-starter/web/src/styles/base-css.ts +0 -3
- package/templates/lupine-template-fullstack-starter/web/src/styles/theme.ts +1 -2
- package/templates/lupine-template-responsive-starter/README.md +46 -2
- package/templates/lupine-template-responsive-starter/app/package.json +19 -0
- package/templates/lupine-template-responsive-starter/app/src/app.tsx +80 -0
- package/templates/lupine-template-responsive-starter/app/src/index.native.tsx +4 -0
- package/templates/lupine-template-responsive-starter/app/src/index.test.tsx +283 -0
- package/templates/lupine-template-responsive-starter/app/src/index.web.tsx +31 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/about.tsx +23 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/finance.tsx +48 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/mine.tsx +60 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/not-found.tsx +9 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/note-detail.tsx +43 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/note-edit.tsx +45 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/note-search.tsx +62 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/notes.tsx +71 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/settings.tsx +55 -0
- package/templates/lupine-template-responsive-starter/app/src/pages/tools.tsx +112 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/icons.ts +7 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/layout.ts +18 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/locales/zh-CN.ts +89 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/menu.tsx +81 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/nav.ts +12 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/store.ts +72 -0
- package/templates/lupine-template-responsive-starter/app/src/shell/texts.ts +11 -0
- package/templates/lupine-template-responsive-starter/app/tsconfig.json +17 -0
- package/templates/lupine-template-responsive-starter/lupine.json +7 -6
- package/templates/lupine-template-responsive-starter/web/src/index.html +9 -2
- package/templates/lupine-template-responsive-starter/web/src/index.tsx +9 -25
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.html +12 -6
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.tsx +12 -22
- package/templates/common/apps/server/src/app-loader.ts +0 -4
- package/templates/lupine-template-cv-starter/api/resources/config_default.json +0 -6
- package/templates/lupine-template-cv-starter/api/resources/install.sqlite.sql +0 -4
- package/templates/lupine-template-cv-starter/api/src/index.ts +0 -15
- package/templates/lupine-template-cv-starter/web/src/client-env-keys.ts +0 -5
- package/templates/lupine-template-cv-starter/web/src/styles/base-css.ts +0 -15
- package/templates/lupine-template-doc-starter/api/resources/config_default.json +0 -6
- package/templates/lupine-template-doc-starter/api/resources/install.sqlite.sql +0 -4
- package/templates/lupine-template-doc-starter/api/src/index.ts +0 -15
- package/templates/lupine-template-doc-starter/api/src/resources/config_default.json +0 -6
- package/templates/lupine-template-doc-starter/api/src/resources/install.sqlite.sql +0 -4
- package/templates/lupine-template-doc-starter/web/src/client-env-keys.ts +0 -5
- package/templates/lupine-template-doc-starter/web/src/styles/base-css.ts +0 -15
- package/templates/lupine-template-fullstack-starter/web/src/admin_dev/admin-about.tsx +0 -16
- package/templates/lupine-template-fullstack-starter/web/src/admin_dev/admin-patch.ts +0 -22
- package/templates/lupine-template-fullstack-starter/web/src/components/footer-menu.tsx +0 -52
- package/templates/lupine-template-fullstack-starter/web/src/components/footer.tsx +0 -15
- package/templates/lupine-template-fullstack-starter/web/src/components/header.tsx +0 -75
- package/templates/lupine-template-fullstack-starter/web/src/components/login-code-zh.tsx +0 -162
- package/templates/lupine-template-fullstack-starter/web/src/components/login-code.tsx +0 -165
- package/templates/lupine-template-fullstack-starter/web/src/components/login-zh.tsx +0 -118
- package/templates/lupine-template-fullstack-starter/web/src/components/login.tsx +0 -122
- package/templates/lupine-template-fullstack-starter/web/src/components/not-found-page.tsx +0 -12
- package/templates/lupine-template-fullstack-starter/web/src/components/register-zh.tsx +0 -161
- package/templates/lupine-template-fullstack-starter/web/src/components/register.tsx +0 -163
- package/templates/lupine-template-fullstack-starter/web/src/components/reset-password-zh.tsx +0 -166
- package/templates/lupine-template-fullstack-starter/web/src/components/reset-password.tsx +0 -177
- package/templates/lupine-template-fullstack-starter/web/src/components/user-info.tsx +0 -84
- package/templates/lupine-template-fullstack-starter/web/src/frames/admin-page-frame.tsx +0 -48
- package/templates/lupine-template-fullstack-starter/web/src/frames/frame1-page-frame.tsx +0 -61
- package/templates/lupine-template-fullstack-starter/web/src/frames/frame2-page-frame.tsx +0 -61
- package/templates/lupine-template-fullstack-starter/web/src/frames/top-frame.tsx +0 -23
- package/templates/lupine-template-fullstack-starter/web/src/frames/user-page-frame.tsx +0 -90
- package/templates/lupine-template-fullstack-starter/web/src/models/index.ts +0 -15
- package/templates/lupine-template-fullstack-starter/web/src/pages/contact.tsx +0 -105
- package/templates/lupine-template-fullstack-starter/web/src/pages/page1-page.tsx +0 -38
- package/templates/lupine-template-fullstack-starter/web/src/pages/page2-page.tsx +0 -38
- package/templates/lupine-template-fullstack-starter/web/src/pages/user-favorite-page.tsx +0 -58
- package/templates/lupine-template-fullstack-starter/web/src/pages/user-home-page.tsx +0 -27
- package/templates/lupine-template-fullstack-starter/web/src/pages/user-mine-page.tsx +0 -54
- package/templates/lupine-template-fullstack-starter/web/src/pages/user-profile-page-zh.tsx +0 -112
- package/templates/lupine-template-fullstack-starter/web/src/pages/user-profile-page.tsx +0 -112
- package/templates/lupine-template-fullstack-starter/web/src/pages/user1-page.tsx +0 -57
- package/templates/lupine-template-fullstack-starter/web/src/services/shared-data.ts +0 -19
- package/templates/lupine-template-fullstack-starter/web/src/styles/app.css +0 -0
- package/templates/lupine-template-responsive-starter/api/package.json +0 -6
- package/templates/lupine-template-responsive-starter/api/resources/config_default.json +0 -6
- package/templates/lupine-template-responsive-starter/api/resources/install.sqlite.sql +0 -4
- package/templates/lupine-template-responsive-starter/api/src/service/root-api.ts +0 -18
- package/templates/lupine-template-responsive-starter/web/src/app-icons.ts +0 -76
- package/templates/lupine-template-responsive-starter/web/src/components/input-history-component.tsx +0 -93
- package/templates/lupine-template-responsive-starter/web/src/components/mine-about-page.tsx +0 -87
- package/templates/lupine-template-responsive-starter/web/src/components/mine-premium-page.tsx +0 -81
- package/templates/lupine-template-responsive-starter/web/src/components/mine-settings-page.tsx +0 -211
- package/templates/lupine-template-responsive-starter/web/src/components/mobile-top-search-menu.tsx +0 -107
- package/templates/lupine-template-responsive-starter/web/src/components/note-detail.tsx +0 -110
- package/templates/lupine-template-responsive-starter/web/src/components/note-edit.tsx +0 -144
- package/templates/lupine-template-responsive-starter/web/src/components/note-search-page.tsx +0 -188
- package/templates/lupine-template-responsive-starter/web/src/components/search-input.tsx +0 -95
- package/templates/lupine-template-responsive-starter/web/src/components/side-menu-content.tsx +0 -169
- package/templates/lupine-template-responsive-starter/web/src/frames/app-responsive-frame.tsx +0 -53
- package/templates/lupine-template-responsive-starter/web/src/pages/about-page.tsx +0 -32
- package/templates/lupine-template-responsive-starter/web/src/pages/finance-page.tsx +0 -35
- package/templates/lupine-template-responsive-starter/web/src/pages/home-page.tsx +0 -444
- package/templates/lupine-template-responsive-starter/web/src/pages/mine-page.tsx +0 -318
- package/templates/lupine-template-responsive-starter/web/src/pages/tools-page.tsx +0 -35
- package/templates/lupine-template-responsive-starter/web/src/services/local-notes-service.ts +0 -87
- package/templates/lupine-template-responsive-starter/web/src/services/mine-service.ts +0 -45
- package/templates/lupine-template-responsive-starter/web/src/styles/app.css +0 -0
- package/templates/lupine-template-responsive-starter/web/src/styles/base-css.ts +0 -65
- package/templates/lupine-template-responsive-starter/web/src/styles/global.css +0 -2130
- package/templates/lupine-template-responsive-starter/web/src/styles/theme.ts +0 -17
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/01-experience/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/02-projects/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/03-skills/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/04-education/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/01-experience/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/02-projects/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/03-skills/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/04-education/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/index.md +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/01-experience/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/02-projects/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/03-skills/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/04-education/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/markdown-config.ts +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/01-experience/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/02-projects/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/03-skills/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/04-education/index.html +0 -0
- /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/index.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/essentials/index.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/essentials/list.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/guide/install.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/guide/started.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/index.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/index.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/essentials/index.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/essentials/list.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/guide/install.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/guide/started.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/index.md +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/essentials/index.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/essentials/list.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/guide/install.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/guide/started.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/index.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/index.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/markdown-config.ts +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/essentials/index.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/essentials/list.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/guide/install.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/guide/started.html +0 -0
- /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/index.html +0 -0
- /package/templates/{lupine-template-responsive-starter → lupine-template-fullstack-note}/api/src/index.ts +0 -0
- /package/templates/lupine-template-fullstack-starter/{web/assets/images → app/assets}/sample.png +0 -0
- /package/templates/lupine-template-fullstack-starter/web/src/{components → admin/components}/story-props.ts +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createSignal, Show, View } from 'lupine.native.core';
|
|
2
|
+
import { Button, createForm, PasswordField, router, rules, Screen, T, t, TextField, Toast, tr } from 'lupine.native.components';
|
|
3
|
+
import * as icons from 'lupine.core/icons';
|
|
4
|
+
import { api, messageOf, serverAddress } from '../shell/api';
|
|
5
|
+
|
|
6
|
+
type Mode = 'login' | 'register';
|
|
7
|
+
// the rules of the API (api/src/service/user-api.ts); it checks them again
|
|
8
|
+
const NAME_RE = /^[A-Za-z0-9_.@-]{3,50}$/;
|
|
9
|
+
|
|
10
|
+
/** Sign in, or create an account (signed in at once). The account and the notes are on the server. */
|
|
11
|
+
export const Login = () => {
|
|
12
|
+
const [mode, setMode] = createSignal<Mode>('login');
|
|
13
|
+
const [busy, setBusy] = createSignal(false);
|
|
14
|
+
const registering = () => mode() === 'register';
|
|
15
|
+
const required = rules.required();
|
|
16
|
+
let password = () => '';
|
|
17
|
+
const form = createForm(
|
|
18
|
+
{ username: '', password: '', password2: '' },
|
|
19
|
+
{
|
|
20
|
+
username: [required, (v) => registering() && !NAME_RE.test(v.trim()) && t('auth.usernameRule', '3 to 50 characters: letters, digits, _ . @ -')],
|
|
21
|
+
password: [required, (v) => registering() && (rules.min(6)(v) || rules.max(256)(v))],
|
|
22
|
+
password2: (v) => registering() && (required(v) || (v !== password() && t('auth.passwordsDiffer', 'The two passwords differ'))),
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
password = () => form.value('password');
|
|
26
|
+
const submit = async () => {
|
|
27
|
+
if (busy() || !form.validate()) return;
|
|
28
|
+
setBusy(true);
|
|
29
|
+
const { username, password } = form.values();
|
|
30
|
+
const answer = registering() ? await api.register(username.trim(), password) : await api.login(username.trim(), password);
|
|
31
|
+
setBusy(false);
|
|
32
|
+
if (answer.status !== 'ok') return Toast.error(messageOf(answer));
|
|
33
|
+
const name = api.user()?.username || username.trim();
|
|
34
|
+
Toast.success(registering() ? t('auth.registered', 'Welcome, {name}: your account is ready', { name }) : t('auth.welcome', 'Signed in as {name}', { name }));
|
|
35
|
+
router.back();
|
|
36
|
+
};
|
|
37
|
+
return (
|
|
38
|
+
<Screen title={() => (registering() ? t('auth.register', 'Create account') : t('auth.signIn', 'Sign in'))} onBack={() => void router.back()} testID='page-login'>
|
|
39
|
+
<View style={{ padding: 20, gap: 14, width: '100%', maxWidth: 420, alignSelf: 'center' }}>
|
|
40
|
+
<TextField label={tr('auth.username', 'User name')} icon={icons.user} {...form.text('username')} testID='login-username' />
|
|
41
|
+
<PasswordField label={tr('auth.password', 'Password')} {...form.text('password')} onSubmit={() => void (registering() || submit())} testID='login-password' />
|
|
42
|
+
<Show when={registering}>
|
|
43
|
+
<PasswordField label={tr('auth.password2', 'Password again')} {...form.text('password2')} onSubmit={submit} testID='login-password2' />
|
|
44
|
+
</Show>
|
|
45
|
+
<Button title={() => (registering() ? t('auth.register', 'Create account') : t('auth.signIn', 'Sign in'))} kind='primary' block loading={busy} onPress={submit} testID='login-submit' />
|
|
46
|
+
<Button
|
|
47
|
+
title={() => (registering() ? t('auth.haveAccount', 'I already have an account') : t('auth.noAccount', 'Create a new account'))} kind='ghost' block
|
|
48
|
+
onPress={() => setMode(registering() ? 'login' : 'register')} testID='login-switch'
|
|
49
|
+
/>
|
|
50
|
+
<T kind='caption' style={{ textAlign: 'center' }} testID='login-server'>{() => `${t('auth.server', 'Server')}: ${serverAddress() || t('auth.thisSite', 'this site')}`}</T>
|
|
51
|
+
</View>
|
|
52
|
+
</Screen>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Show, View } from 'lupine.native.core';
|
|
2
|
+
import { Avatar, Button, Header, router, Row, Screen, Section, T, t, Toast, tr } from 'lupine.native.components';
|
|
3
|
+
import { api } from '../shell/api';
|
|
4
|
+
import * as icons from 'lupine.core/icons';
|
|
5
|
+
|
|
6
|
+
export const Me = () => {
|
|
7
|
+
const name = () => api.user()?.username || t('me.guest', 'Guest');
|
|
8
|
+
return (
|
|
9
|
+
<Screen header={<Header title={tr('nav.me', 'Me')} />} grouped testID='page-me'>
|
|
10
|
+
<View style={{ alignItems: 'center', gap: 8, paddingTop: 24 }}>
|
|
11
|
+
<Avatar name={name} size={72} />
|
|
12
|
+
<T kind='subtitle' testID='me-name'>{name}</T>
|
|
13
|
+
<Show
|
|
14
|
+
when={api.user}
|
|
15
|
+
fallback={<Button title={tr('me.signIn', 'Sign in')} kind='primary' size='small' onPress={() => router.push('/login')} testID='me-signin' />}
|
|
16
|
+
>
|
|
17
|
+
<Button title={tr('auth.signOut', 'Sign out')} size='small' onPress={() => void api.logout()} testID='me-signout' />
|
|
18
|
+
</Show>
|
|
19
|
+
</View>
|
|
20
|
+
<Section>
|
|
21
|
+
<Row label={tr('notes.title', 'My notes')} icon={icons.edit} iconColor='#34c759' onPress={() => router.push('/notes')} testID='me-notes' />
|
|
22
|
+
<Row label={tr('me.profile', 'Profile')} icon={icons.user} iconColor='#1677ff' onPress={() => Toast.info(t('me.profile', 'Profile'))} />
|
|
23
|
+
<Row label={tr('me.favourites', 'Favourites')} icon={icons.heart} iconColor='#ff375f' onPress={() => Toast.info(t('me.favourites', 'Favourites'))} />
|
|
24
|
+
<Row label={tr('me.history', 'History')} icon={icons.clock} iconColor='#ff9f0a' onPress={() => Toast.info(t('me.history', 'History'))} />
|
|
25
|
+
</Section>
|
|
26
|
+
<Section>
|
|
27
|
+
<Row label={tr('nav.settings', 'Settings')} icon={icons.settings} iconColor='#8e8e93' onPress={() => router.push('/settings')} testID='me-settings' />
|
|
28
|
+
<Row label={tr('me.help', 'Help & feedback')} icon={icons.help} iconColor='#30b0c7' onPress={() => router.push('/about')} />
|
|
29
|
+
</Section>
|
|
30
|
+
</Screen>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createEffect, createMemo, createSignal, For, Show, untrack, View } from 'lupine.native.core';
|
|
2
|
+
import { Button, Card, col, EmptyView, Icon, IconButton, router, Screen, T, t, TextField, Toast, tr } from 'lupine.native.components';
|
|
3
|
+
import * as icons from 'lupine.core/icons';
|
|
4
|
+
import { api, messageOf, Note } from '../shell/api';
|
|
5
|
+
|
|
6
|
+
/** the time of a note (ISO, UTC) in the time zone of the device */
|
|
7
|
+
const when = (iso: string) => {
|
|
8
|
+
const d = new Date(iso);
|
|
9
|
+
if (Number.isNaN(d.getTime())) return iso;
|
|
10
|
+
const two = (n: number) => (n < 10 ? '0' : '') + n;
|
|
11
|
+
return `${d.getFullYear()}-${two(d.getMonth() + 1)}-${two(d.getDate())} ${two(d.getHours())}:${two(d.getMinutes())}`;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** The notes of the signed-in user, on the server: newest first, pull down (or the button) to load them again. */
|
|
15
|
+
export const Notes = () => {
|
|
16
|
+
const [notes, setNotes] = createSignal<Note[]>([]);
|
|
17
|
+
const [more, setMore] = createSignal(false);
|
|
18
|
+
const [loading, setLoading] = createSignal(false);
|
|
19
|
+
const [loaded, setLoaded] = createSignal(false);
|
|
20
|
+
// the message of the last load that failed (offline, an error of the server); the notes of before stay
|
|
21
|
+
const [error, setError] = createSignal('');
|
|
22
|
+
const [text, setText] = createSignal('');
|
|
23
|
+
const [adding, setAdding] = createSignal(false);
|
|
24
|
+
|
|
25
|
+
const load = async (older = false): Promise<void> => {
|
|
26
|
+
const uid = api.user()?.id;
|
|
27
|
+
if (!uid || loading()) return;
|
|
28
|
+
setLoading(true);
|
|
29
|
+
const list = notes();
|
|
30
|
+
const answer = await api.notes(older && list.length ? list[list.length - 1].id : undefined);
|
|
31
|
+
setLoading(false);
|
|
32
|
+
// the session is over: signed out already (shell/api.ts), the page asks to sign in again
|
|
33
|
+
if (answer.code === 'not_signed_in') {
|
|
34
|
+
Toast.info(messageOf(answer));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// signed out meanwhile, or in as someone else: not these notes
|
|
38
|
+
if (api.user()?.id !== uid) return api.user() ? load() : undefined;
|
|
39
|
+
if (answer.status !== 'ok') {
|
|
40
|
+
setError(messageOf(answer));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
setNotes(older ? [...list, ...(answer.notes || [])] : answer.notes || []);
|
|
44
|
+
setMore(!!answer.more);
|
|
45
|
+
setLoaded(true);
|
|
46
|
+
setError('');
|
|
47
|
+
};
|
|
48
|
+
// when someone signs in (and again for another user); signed out: nothing is left on the page
|
|
49
|
+
const userId = createMemo(() => api.user()?.id ?? null);
|
|
50
|
+
createEffect(() => {
|
|
51
|
+
if (userId() !== null) return untrack(() => void load());
|
|
52
|
+
setNotes([]);
|
|
53
|
+
setMore(false);
|
|
54
|
+
setLoaded(false);
|
|
55
|
+
setError('');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const add = async () => {
|
|
59
|
+
const value = text().trim();
|
|
60
|
+
if (!value || adding()) return;
|
|
61
|
+
setAdding(true);
|
|
62
|
+
const answer = await api.addNote(value);
|
|
63
|
+
setAdding(false);
|
|
64
|
+
if (answer.status === 'ok' && answer.note) {
|
|
65
|
+
setNotes([answer.note, ...notes()]);
|
|
66
|
+
setText('');
|
|
67
|
+
} else Toast.error(messageOf(answer));
|
|
68
|
+
};
|
|
69
|
+
const remove = async (n: Note) => {
|
|
70
|
+
const answer = await api.deleteNote(n.id);
|
|
71
|
+
// gone already: gone here, too
|
|
72
|
+
if (answer.status === 'ok' || answer.code === 'note_not_found') {
|
|
73
|
+
setNotes(notes().filter((x) => x.id !== n.id));
|
|
74
|
+
Toast.info(t('notes.deleted', 'Note deleted'));
|
|
75
|
+
} else Toast.error(messageOf(answer));
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<Screen
|
|
80
|
+
title={tr('notes.title', 'My notes')} onBack={() => void router.back()} testID='page-notes'
|
|
81
|
+
right={<Show when={api.user}><IconButton name={icons.refresh} onPress={() => void load()} testID='notes-refresh' /></Show>}
|
|
82
|
+
refreshing={loading} onRefresh={() => void load()}
|
|
83
|
+
>
|
|
84
|
+
<View style={{ padding: 16, gap: 12, width: '100%', maxWidth: 720, alignSelf: 'center' }}>
|
|
85
|
+
<Show
|
|
86
|
+
when={api.user}
|
|
87
|
+
fallback={
|
|
88
|
+
<View style={{ alignItems: 'center', padding: 32, gap: 12 }}>
|
|
89
|
+
<Icon name={icons.lock} size={42} color={col('textTertiary')} />
|
|
90
|
+
<T kind='subtitle' style={{ textAlign: 'center' }} testID='notes-signed-out'>{tr('notes.signInFirst', 'Sign in to keep notes on the server')}</T>
|
|
91
|
+
<T kind='secondary' style={{ textAlign: 'center' }}>{tr('notes.signInText', 'They are kept with your account, so you have them on every device and on the web.')}</T>
|
|
92
|
+
<Button title={tr('auth.signIn', 'Sign in')} kind='primary' onPress={() => router.push('/login')} testID='notes-signin' />
|
|
93
|
+
</View>
|
|
94
|
+
}
|
|
95
|
+
>
|
|
96
|
+
<View style={{ flexDirection: 'row', gap: 8, alignItems: 'flex-end' }}>
|
|
97
|
+
<TextField containerStyle={{ flex: 1 }} value={text} onChangeText={setText} placeholder={tr('notes.placeholder', 'Write a note…')} maxLength={2000} onSubmit={add} testID='note-input' />
|
|
98
|
+
<Button title={tr('notes.add', 'Add')} kind='primary' onPress={add} loading={adding} disabled={() => !text().trim()} testID='note-add' />
|
|
99
|
+
</View>
|
|
100
|
+
<Show when={error}>
|
|
101
|
+
<Card style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
|
|
102
|
+
<Icon name={icons.warning} color={col('error')} />
|
|
103
|
+
<T style={{ flex: 1 }} testID='notes-error'>{error}</T>
|
|
104
|
+
<Button title={tr('notes.retry', 'Try again')} size='small' onPress={() => void load()} testID='notes-retry' />
|
|
105
|
+
</Card>
|
|
106
|
+
</Show>
|
|
107
|
+
<Show when={() => loaded() && !notes().length && !error()}>
|
|
108
|
+
<EmptyView icon={icons.edit} title={tr('notes.empty', 'No notes yet')} />
|
|
109
|
+
</Show>
|
|
110
|
+
<For each={notes}>
|
|
111
|
+
{(n) => (
|
|
112
|
+
<Card style={{ flexDirection: 'row', alignItems: 'center', gap: 8 }}>
|
|
113
|
+
<View style={{ flex: 1 }}>
|
|
114
|
+
<T testID={`note-${n.id}`}>{n.text}</T>
|
|
115
|
+
<T kind='caption'>{when(n.created_at)}</T>
|
|
116
|
+
</View>
|
|
117
|
+
<IconButton name={icons.trash} testID={`note-delete-${n.id}`} onPress={() => void remove(n)} />
|
|
118
|
+
</Card>
|
|
119
|
+
)}
|
|
120
|
+
</For>
|
|
121
|
+
<Show when={more}>
|
|
122
|
+
<Button title={tr('notes.more', 'Older notes')} kind='ghost' block loading={loading} onPress={() => void load(true)} testID='notes-more' />
|
|
123
|
+
</Show>
|
|
124
|
+
</Show>
|
|
125
|
+
</View>
|
|
126
|
+
</Screen>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createSignal, Slider, Switch } from 'lupine.native.core';
|
|
2
|
+
import { ActionSheet, lang, languages, MessageBox, router, Row, Screen, Section, setLang, setThemePref, t, themePref, themes, Toast, tr } from 'lupine.native.components';
|
|
3
|
+
import * as icons from 'lupine.core/icons';
|
|
4
|
+
import { serverAddress } from '../shell/api';
|
|
5
|
+
|
|
6
|
+
export const Settings = () => {
|
|
7
|
+
const [push, setPush] = createSignal(true);
|
|
8
|
+
const [sound, setSound] = createSignal(false);
|
|
9
|
+
const [size, setSize] = createSignal(1);
|
|
10
|
+
const label = (n: string) => (n === 'system' ? t('ln.themeSystem', 'System') : n === 'light' ? t('ln.themeLight', 'Light') : n === 'dark' ? t('ln.themeDark', 'Dark') : n);
|
|
11
|
+
const pickTheme = async () => {
|
|
12
|
+
const v = await ActionSheet.select({ title: t('settings.theme', 'Theme'), selected: themePref(), options: ['system', ...Object.keys(themes)].map((n) => ({ label: label(n), value: n })) });
|
|
13
|
+
if (v) setThemePref(v);
|
|
14
|
+
};
|
|
15
|
+
const pickLang = async () => {
|
|
16
|
+
const v = await ActionSheet.select({ title: t('settings.language', 'Language'), selected: lang(), options: languages.map((l) => ({ label: l.name, value: l.code })) });
|
|
17
|
+
if (v) setLang(v);
|
|
18
|
+
};
|
|
19
|
+
const clear = async () => {
|
|
20
|
+
if (await MessageBox.confirm({ message: t('settings.clearCache', 'Clear cache') + '?', okText: t('ln.delete', 'Delete'), destructive: true })) Toast.success(t('settings.cacheCleared', 'Cache cleared'));
|
|
21
|
+
};
|
|
22
|
+
return (
|
|
23
|
+
<Screen title={tr('nav.settings', 'Settings')} onBack={() => void router.back()} grouped testID='page-settings'>
|
|
24
|
+
<Section title={tr('settings.appearance', 'Appearance')}>
|
|
25
|
+
<Row label={tr('settings.theme', 'Theme')} icon={icons.palette} iconColor='#5e5ce6' value={() => label(themePref())} onPress={pickTheme} testID='settings-theme' />
|
|
26
|
+
<Row label={tr('settings.language', 'Language')} icon={icons.language} iconColor='#34c759' value={() => languages.find((l) => l.code === lang())!.name} onPress={pickLang} testID='settings-language' />
|
|
27
|
+
<Row label={tr('settings.textSize', 'Text size')} icon={icons.edit} iconColor='#ff9f0a' value={() => `${Math.round(size() * 100)}%`} testID='settings-size'>
|
|
28
|
+
<Slider value={size} min={0.8} max={1.4} step={0.1} onValueChange={setSize} testID='size-slider' />
|
|
29
|
+
</Row>
|
|
30
|
+
</Section>
|
|
31
|
+
<Section title={tr('settings.notifications', 'Notifications')}>
|
|
32
|
+
<Row label={tr('settings.pushEnabled', 'Push notifications')} icon={icons.bell} iconColor='#ff3b30' right={<Switch value={push} onValueChange={setPush} testID='settings-push' />} />
|
|
33
|
+
<Row label={tr('settings.sound', 'Sound')} icon={icons.volume} iconColor='#ff2d55' right={<Switch value={sound} onValueChange={setSound} />} />
|
|
34
|
+
</Section>
|
|
35
|
+
<Section title={tr('settings.storage', 'Storage')}>
|
|
36
|
+
<Row label={tr('settings.clearCache', 'Clear cache')} destructive onPress={clear} testID='settings-clear' />
|
|
37
|
+
</Section>
|
|
38
|
+
<Section title={tr('settings.app', 'App')}>
|
|
39
|
+
{/* the API: WEB.API_BASE_URL of the env file of the build; the web version uses the site it comes from */}
|
|
40
|
+
<Row label={tr('settings.server', 'Server')} value={() => serverAddress() || t('settings.thisSite', 'This site')} testID='settings-server' />
|
|
41
|
+
<Row label={tr('settings.version', 'Version')} value='0.1.0' />
|
|
42
|
+
</Section>
|
|
43
|
+
</Screen>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createSignal, media, Text, View } from 'lupine.native.core';
|
|
2
|
+
import { col, Icon, IconButton, router, Row, Section, setThemePref, SideMenu, t, theme, tr } from 'lupine.native.components';
|
|
3
|
+
import * as icons from 'lupine.core/icons';
|
|
4
|
+
|
|
5
|
+
/** The menu button of the header (phones only) and the drawer it opens. */
|
|
6
|
+
export const createAppMenu = () => {
|
|
7
|
+
const [open, setOpen] = createSignal(false);
|
|
8
|
+
const go = (path: string) => {
|
|
9
|
+
setOpen(false);
|
|
10
|
+
setTimeout(() => router.push(path), 120);
|
|
11
|
+
};
|
|
12
|
+
// phones only (css on the web)
|
|
13
|
+
const button = (
|
|
14
|
+
<View style={{ display: media<'flex' | 'none'>({ base: 'flex', mobileAbove: 'none' }) }}>
|
|
15
|
+
<IconButton name={icons.menu} onPress={() => setOpen(true)} testID='menu-button' />
|
|
16
|
+
</View>
|
|
17
|
+
);
|
|
18
|
+
const menu = (
|
|
19
|
+
<SideMenu visible={open} onClose={() => setOpen(false)} testID='side-menu'>
|
|
20
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10, padding: 18 }}>
|
|
21
|
+
<Icon name={icons.logo} size={28} color={col('primary')} />
|
|
22
|
+
<View style={{ flex: 1 }}>
|
|
23
|
+
<Text numberOfLines={1} style={{ fontSize: 17, fontWeight: '700', color: col('text') }}>{tr('app.name', 'Lupine Notes')}</Text>
|
|
24
|
+
<Text numberOfLines={2} style={{ fontSize: 12, color: col('textSecondary') }}>{tr('app.tagline', 'One code base for iOS, Android, web and desktop')}</Text>
|
|
25
|
+
</View>
|
|
26
|
+
</View>
|
|
27
|
+
<Section>
|
|
28
|
+
<Row label={tr('nav.settings', 'Settings')} icon={icons.settings} iconColor='#8e8e93' onPress={() => go('/settings')} testID='menu-settings' />
|
|
29
|
+
<Row label={tr('nav.about', 'About')} icon={icons.info} iconColor='#1677ff' onPress={() => go('/about')} />
|
|
30
|
+
</Section>
|
|
31
|
+
<Section title={tr('settings.theme', 'Theme')}>
|
|
32
|
+
<Row
|
|
33
|
+
label={() => (theme().mode === 'dark' ? t('ln.themeLight', 'Light') : t('ln.themeDark', 'Dark'))}
|
|
34
|
+
icon={() => (theme().mode === 'dark' ? icons.sun : icons.moon)}
|
|
35
|
+
iconColor='#5e5ce6'
|
|
36
|
+
onPress={() => setThemePref(theme().mode === 'dark' ? 'light' : 'dark')}
|
|
37
|
+
chevron={false}
|
|
38
|
+
testID='menu-theme'
|
|
39
|
+
/>
|
|
40
|
+
</Section>
|
|
41
|
+
</SideMenu>
|
|
42
|
+
);
|
|
43
|
+
return { button, menu };
|
|
44
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { createSignal, Platform, storage, webEnv } from 'lupine.native.core';
|
|
2
|
+
import { lang, t } from 'lupine.native.components';
|
|
3
|
+
|
|
4
|
+
// The API of this template (api/src/service/api.ts, routes under /api), with fetch on every platform.
|
|
5
|
+
//
|
|
6
|
+
// The server: in the browser the page comes from it, so it is the same address (''), whatever the env file says. A
|
|
7
|
+
// native app needs its address: WEB.API_BASE_URL of the env file (lupine-native --env; .env.mobile for the apps of the
|
|
8
|
+
// stores; the key is public, it goes into the bundle), otherwise `npm run dev` on this computer (from the Android
|
|
9
|
+
// emulator 10.0.2.2).
|
|
10
|
+
//
|
|
11
|
+
// The session: the API answers a sign-in with the cookie _token (httpOnly). The browser keeps it and sends it, and
|
|
12
|
+
// scripts never see it. A native app has no cookie jar: it keeps the token of the answer with storage and sends it as
|
|
13
|
+
// the cookie of each request itself.
|
|
14
|
+
//
|
|
15
|
+
// The answers: { status: 'ok' | 'error', code, message }. The app shows its own text for the code (messageOf), in the
|
|
16
|
+
// language of the user; the message of the API is English.
|
|
17
|
+
|
|
18
|
+
export interface User {
|
|
19
|
+
id: number;
|
|
20
|
+
username: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Note {
|
|
23
|
+
id: number;
|
|
24
|
+
text: string;
|
|
25
|
+
created_at: string;
|
|
26
|
+
updated_at: string;
|
|
27
|
+
}
|
|
28
|
+
/** what the API answers; code 'offline': the server wasn't reached, 'bad_answer': not an answer of the API */
|
|
29
|
+
export interface Answer {
|
|
30
|
+
status: 'ok' | 'error';
|
|
31
|
+
code: string;
|
|
32
|
+
message?: string;
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const native = Platform.OS !== 'web';
|
|
37
|
+
const port = webEnv('API_PORT', 11080);
|
|
38
|
+
const local = `http://${Platform.OS === 'android' ? '10.0.2.2' : 'lupine-template-fullstack-note.app.localhost'}:${port}`;
|
|
39
|
+
let base = native ? (webEnv('API_BASE_URL', '') || local).replace(/\/+$/, '') : '';
|
|
40
|
+
|
|
41
|
+
/** 'http://host:port'; '' in the browser (the server of the page) */
|
|
42
|
+
export const serverAddress = () => base;
|
|
43
|
+
/** another server, such as one that isn't there (the tests) */
|
|
44
|
+
export const setServerAddress = (address: string) => {
|
|
45
|
+
base = address.replace(/\/+$/, '');
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** The text of an answer for the user, by its code. A code the app doesn't know: the message of the API. */
|
|
49
|
+
export const messageOf = (a: Answer): string => {
|
|
50
|
+
switch (a.code) {
|
|
51
|
+
case 'offline': return t('api.offline', 'The server cannot be reached');
|
|
52
|
+
case 'bad_answer': return t('api.bad_answer', 'Unexpected answer of the server ({status})', { status: a.httpStatus ?? '?' });
|
|
53
|
+
case 'bad_request': return t('api.bad_request', 'The server did not understand the request');
|
|
54
|
+
case 'bad_username': return t('api.bad_username', 'User name: 3 to 50 characters (letters, digits, _ . @ -)');
|
|
55
|
+
case 'bad_password': return t('api.bad_password', 'Password: 6 to 256 characters');
|
|
56
|
+
case 'username_taken': return t('api.username_taken', 'This user name is taken');
|
|
57
|
+
case 'login_failed': return t('api.login_failed', 'Wrong user name or password');
|
|
58
|
+
case 'too_many_attempts': return t('api.too_many_attempts', 'Too many failed sign-ins. Try again in {minutes} minutes', { minutes: a.minutes ?? 15 });
|
|
59
|
+
case 'not_signed_in': return t('api.not_signed_in', 'Please sign in again');
|
|
60
|
+
case 'bad_note': return t('api.bad_note', 'A note has 1 to 2000 characters');
|
|
61
|
+
case 'too_many_notes': return t('api.too_many_notes', 'At most {max} notes: delete some first', { max: a.max ?? 500 });
|
|
62
|
+
case 'note_not_found': return t('api.note_not_found', 'This note is gone');
|
|
63
|
+
case 'no_crypto_key': return t('api.no_crypto_key', 'The server has no CRYPTO_KEY in its .env');
|
|
64
|
+
case 'forbidden_origin': return t('api.forbidden_origin', 'The server refused a request from this page');
|
|
65
|
+
case 'server_error': return t('api.server_error', 'Something went wrong on the server');
|
|
66
|
+
default: return a.message || t('api.failed', 'Something went wrong');
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// a native app only: the token of the session, and the user, so that the app knows it at once and offline
|
|
71
|
+
const TOKEN = 'session';
|
|
72
|
+
const USER = 'user';
|
|
73
|
+
const cached = (): User | null => {
|
|
74
|
+
if (!native) return null;
|
|
75
|
+
try {
|
|
76
|
+
const u = JSON.parse(storage.get(USER) || 'null');
|
|
77
|
+
return u && typeof u.username === 'string' ? u : null;
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
// On the web this stays null while the server renders a page (the modules are shared by all requests): the browser asks
|
|
83
|
+
// who is signed in (api.refresh in onMount of the app).
|
|
84
|
+
const [user, setUser] = createSignal<User | null>(cached());
|
|
85
|
+
const keep = (u: User | null | undefined) => {
|
|
86
|
+
const value = u ? { id: Number(u.id), username: String(u.username) } : null;
|
|
87
|
+
setUser(value);
|
|
88
|
+
if (native) storage.set(USER, value ? JSON.stringify(value) : null);
|
|
89
|
+
};
|
|
90
|
+
const forget = () => {
|
|
91
|
+
keep(null);
|
|
92
|
+
if (native) storage.set(TOKEN, null);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const call = async (path: string, body?: object): Promise<Answer> => {
|
|
96
|
+
const headers: { [name: string]: string } = { Accept: 'application/json' };
|
|
97
|
+
if (body) headers['Content-Type'] = 'application/json';
|
|
98
|
+
if (native) {
|
|
99
|
+
// what a browser sends by itself
|
|
100
|
+
const token = storage.get(TOKEN);
|
|
101
|
+
headers.Cookie = `lang=${encodeURIComponent(lang())}` + (token ? `; _token=${encodeURIComponent(token)}` : '');
|
|
102
|
+
}
|
|
103
|
+
const abort = new AbortController();
|
|
104
|
+
const timer = setTimeout(() => abort.abort(), 20000);
|
|
105
|
+
let answer: Answer;
|
|
106
|
+
try {
|
|
107
|
+
const response = await fetch(base + path, { method: body ? 'POST' : 'GET', headers, body: body ? JSON.stringify(body) : undefined, signal: abort.signal });
|
|
108
|
+
const text = await response.text();
|
|
109
|
+
try {
|
|
110
|
+
const json = JSON.parse(text);
|
|
111
|
+
answer = json && typeof json === 'object' && typeof json.status === 'string' ? { code: json.status === 'ok' ? 'ok' : 'failed', ...json } : { status: 'error', code: 'bad_answer', httpStatus: response.status };
|
|
112
|
+
} catch {
|
|
113
|
+
answer = { status: 'error', code: 'bad_answer', httpStatus: response.status };
|
|
114
|
+
}
|
|
115
|
+
} catch {
|
|
116
|
+
answer = { status: 'error', code: 'offline' };
|
|
117
|
+
} finally {
|
|
118
|
+
clearTimeout(timer);
|
|
119
|
+
}
|
|
120
|
+
// the session is over (a new password, too old): signed out here as well
|
|
121
|
+
if (answer.code === 'not_signed_in' && user()) forget();
|
|
122
|
+
return answer;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/** after a sign-in or a new account: an app keeps the token */
|
|
126
|
+
const signedIn = (answer: Answer) => {
|
|
127
|
+
if (answer.status !== 'ok') return answer;
|
|
128
|
+
if (native) storage.set(TOKEN, String(answer.token || ''));
|
|
129
|
+
keep(answer.user);
|
|
130
|
+
return answer;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const api = {
|
|
134
|
+
user,
|
|
135
|
+
/** who is signed in: the browser by its cookie, an app by its token. Offline an app keeps the user it knows. */
|
|
136
|
+
refresh: async () => {
|
|
137
|
+
if (native && !storage.get(TOKEN)) return forget();
|
|
138
|
+
const answer = await call('/api/me');
|
|
139
|
+
if (answer.status === 'ok') keep(answer.user);
|
|
140
|
+
else if (answer.code === 'not_signed_in') forget();
|
|
141
|
+
},
|
|
142
|
+
login: async (username: string, password: string) => signedIn(await call('/api/login', { username, password })),
|
|
143
|
+
/** a new account, signed in at once */
|
|
144
|
+
register: async (username: string, password: string) => signedIn(await call('/api/register', { username, password })),
|
|
145
|
+
logout: async () => {
|
|
146
|
+
// the request has the token already: signed out here at once, also offline
|
|
147
|
+
const told = call('/api/logout', {});
|
|
148
|
+
forget();
|
|
149
|
+
await told;
|
|
150
|
+
},
|
|
151
|
+
/** sign out on this device only */
|
|
152
|
+
forget,
|
|
153
|
+
|
|
154
|
+
/** the newest notes (before: the id of the last one shown, for the next page); more: there are older ones */
|
|
155
|
+
notes: (before?: number) => call(`/api/notes${before ? `?before=${before}` : ''}`) as Promise<Answer & { notes?: Note[]; more?: boolean }>,
|
|
156
|
+
addNote: (text: string) => call('/api/notes/add', { text }) as Promise<Answer & { note?: Note }>,
|
|
157
|
+
updateNote: (id: number, text: string) => call('/api/notes/update', { id, text }) as Promise<Answer & { note?: Note }>,
|
|
158
|
+
deleteNote: (id: number) => call('/api/notes/delete', { id }),
|
|
159
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as icons from 'lupine.core/icons';
|
|
2
|
+
/** sample content for the template pages (replace with API data) */
|
|
3
|
+
export const FEATURED = [
|
|
4
|
+
{ id: '1', title: 'Getting started', subtitle: 'Pages live in src/pages', color: '#1677ff' },
|
|
5
|
+
{ id: '2', title: 'Themes', subtitle: 'Light, dark and derived themes', color: '#7a5af8' },
|
|
6
|
+
{ id: '3', title: 'Everywhere', subtitle: 'iOS · Android · Web · Desktop', color: '#12b886' },
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
export const RECENT = [
|
|
10
|
+
{ id: '11', title: 'Quarterly report', when: '2 hours ago', icon: icons.file },
|
|
11
|
+
{ id: '12', title: 'Team photos', when: 'Yesterday', icon: icons.image },
|
|
12
|
+
{ id: '13', title: 'Release checklist', when: 'Monday', icon: icons.list },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export const MESSAGES = [
|
|
16
|
+
{ id: 'm1', from: 'Lupine', text: 'Welcome to Lupine Notes!', unread: true, when: '09:12' },
|
|
17
|
+
{ id: 'm2', from: 'Build bot', text: 'Web build finished in 18 s', unread: true, when: '08:40' },
|
|
18
|
+
{ id: 'm3', from: 'Ada', text: 'Can you review the new settings page?', unread: true, when: 'Yesterday' },
|
|
19
|
+
{ id: 'm4', from: 'Grace', text: 'Desktop app runs on Windows too.', unread: false, when: 'Monday' },
|
|
20
|
+
];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export const ja = {
|
|
2
|
+
app: { name: 'Lupine ノート', tagline: 'iOS・Android・Web・デスクトップを一つのコードで' },
|
|
3
|
+
nav: { home: 'ホーム', components: 'コンポーネント', discover: '作成', inbox: '受信箱', me: 'マイページ', settings: '設定', about: 'このアプリについて', menu: 'メニュー' },
|
|
4
|
+
home: {
|
|
5
|
+
welcome: 'おかえりなさい',
|
|
6
|
+
featured: 'おすすめ',
|
|
7
|
+
shortcuts: 'ショートカット',
|
|
8
|
+
recent: '最近の項目',
|
|
9
|
+
openPanel: 'スライドウィンドウを開く',
|
|
10
|
+
panelText: 'このウィンドウは現在のページの上にスライドして表示されます。URL が不要な詳細やフォームに使います。',
|
|
11
|
+
seeAll: 'すべて',
|
|
12
|
+
},
|
|
13
|
+
discover: { title: '新規作成', note: 'ノート', photo: '写真を撮る', task: 'タスク', created: '作成しました:{what}' },
|
|
14
|
+
inbox: { empty: '新しいメッセージはありません', markRead: 'すべて既読にする', unread: '未読 {n} 件' },
|
|
15
|
+
me: { guest: 'ゲスト', signIn: 'ログイン', profile: 'プロフィール', favourites: 'お気に入り', history: '履歴', help: 'ヘルプとフィードバック' },
|
|
16
|
+
settings: {
|
|
17
|
+
appearance: '外観',
|
|
18
|
+
theme: 'テーマ',
|
|
19
|
+
language: '言語',
|
|
20
|
+
textSize: '文字サイズ',
|
|
21
|
+
notifications: '通知',
|
|
22
|
+
pushEnabled: 'プッシュ通知',
|
|
23
|
+
sound: 'サウンド',
|
|
24
|
+
storage: 'ストレージ',
|
|
25
|
+
clearCache: 'キャッシュを消去',
|
|
26
|
+
cacheCleared: 'キャッシュを消去しました',
|
|
27
|
+
app: 'アプリ',
|
|
28
|
+
server: 'サーバー',
|
|
29
|
+
thisSite: 'このサイト',
|
|
30
|
+
version: 'バージョン',
|
|
31
|
+
},
|
|
32
|
+
item: { title: '項目 {id}', body: '詳細ページは通常のルート(/item/[id])です。ディープリンクとブラウザの戻るが使え、Web サーバーで描画することもできます。' },
|
|
33
|
+
auth: {
|
|
34
|
+
signIn: 'ログイン',
|
|
35
|
+
register: 'アカウント作成',
|
|
36
|
+
username: 'ユーザー名',
|
|
37
|
+
usernameRule: '3〜50 文字:英字、数字、_ . @ -',
|
|
38
|
+
password: 'パスワード',
|
|
39
|
+
password2: 'パスワード(確認)',
|
|
40
|
+
passwordsDiffer: 'パスワードが一致しません',
|
|
41
|
+
haveAccount: 'アカウントをお持ちの方',
|
|
42
|
+
noAccount: '新しいアカウントを作成',
|
|
43
|
+
signOut: 'ログアウト',
|
|
44
|
+
welcome: '{name} としてログイン中',
|
|
45
|
+
registered: 'ようこそ、{name} さん:アカウントを作成しました',
|
|
46
|
+
server: 'サーバー',
|
|
47
|
+
thisSite: 'このサイト',
|
|
48
|
+
},
|
|
49
|
+
notes: {
|
|
50
|
+
title: 'マイノート',
|
|
51
|
+
placeholder: 'メモを書く…',
|
|
52
|
+
add: '追加',
|
|
53
|
+
empty: 'ノートはまだありません',
|
|
54
|
+
signInFirst: 'ログインするとサーバーに保存できます',
|
|
55
|
+
signInText: 'ノートはアカウントに保存され、どの端末でも Web でも見られます。',
|
|
56
|
+
deleted: '削除しました',
|
|
57
|
+
retry: '再試行',
|
|
58
|
+
more: '以前のノート',
|
|
59
|
+
},
|
|
60
|
+
// the texts of the codes of the API (shell/api.ts: messageOf)
|
|
61
|
+
api: {
|
|
62
|
+
offline: 'サーバーに接続できません',
|
|
63
|
+
bad_answer: 'サーバーから予期しない応答がありました({status})',
|
|
64
|
+
bad_request: 'サーバーがリクエストを理解できませんでした',
|
|
65
|
+
bad_username: 'ユーザー名:3〜50 文字(英字、数字、_ . @ -)',
|
|
66
|
+
bad_password: 'パスワード:6〜256 文字',
|
|
67
|
+
username_taken: 'このユーザー名は使われています',
|
|
68
|
+
login_failed: 'ユーザー名またはパスワードが違います',
|
|
69
|
+
too_many_attempts: 'ログインの失敗が多すぎます。{minutes} 分後にもう一度お試しください',
|
|
70
|
+
not_signed_in: 'もう一度ログインしてください',
|
|
71
|
+
bad_note: 'ノートは 1〜2000 文字です',
|
|
72
|
+
too_many_notes: 'ノートは最大 {max} 件です:いくつか削除してください',
|
|
73
|
+
note_not_found: 'このノートはもうありません',
|
|
74
|
+
no_crypto_key: 'サーバーの .env に CRYPTO_KEY がありません',
|
|
75
|
+
forbidden_origin: 'このページからのリクエストはサーバーに拒否されました',
|
|
76
|
+
server_error: 'サーバーでエラーが発生しました',
|
|
77
|
+
failed: 'エラーが発生しました',
|
|
78
|
+
},
|
|
79
|
+
about: { text: 'lupine.native で作られています。ページは src/pages、フレームは src/shell を編集します。' },
|
|
80
|
+
};
|