@shuvi/platform-web 0.0.1-rc.32 → 1.0.0-rc.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 (233) hide show
  1. package/esm/shared/appTypes.d.ts +15 -0
  2. package/esm/shared/appTypes.js +1 -0
  3. package/esm/shared/index.d.ts +4 -0
  4. package/esm/shared/index.js +4 -0
  5. package/esm/shared/renderTypes.d.ts +44 -0
  6. package/esm/shared/renderTypes.js +1 -0
  7. package/esm/shared/routeTypes.d.ts +47 -0
  8. package/esm/shared/routeTypes.js +1 -0
  9. package/esm/shared/serverTypes.d.ts +6 -0
  10. package/esm/shared/serverTypes.js +1 -0
  11. package/esm/shuvi-app/app/client.d.ts +2 -0
  12. package/esm/shuvi-app/app/client.js +125 -0
  13. package/esm/shuvi-app/app/server.d.ts +2 -0
  14. package/esm/shuvi-app/app/server.js +67 -0
  15. package/{shuvi-app → esm/shuvi-app}/dev/webpackHotDevClient.d.ts +0 -0
  16. package/{shuvi-app → esm/shuvi-app}/dev/webpackHotDevClient.js +0 -0
  17. package/esm/shuvi-app/entry/client/app.d.ts +2 -0
  18. package/esm/shuvi-app/entry/client/app.js +57 -0
  19. package/esm/shuvi-app/entry/client/index.d.ts +2 -0
  20. package/esm/shuvi-app/entry/client/index.js +12 -0
  21. package/{shuvi-app → esm/shuvi-app}/entry/client/run.dev.d.ts +0 -0
  22. package/{shuvi-app → esm/shuvi-app}/entry/client/run.dev.js +2 -2
  23. package/{shuvi-app → esm/shuvi-app}/entry/client/run.prod.d.ts +0 -0
  24. package/esm/shuvi-app/entry/client/run.prod.js +3 -0
  25. package/{shuvi-app → esm/shuvi-app}/entry/client/setup-env.d.ts +1 -1
  26. package/esm/shuvi-app/entry/client/setup-env.js +17 -0
  27. package/esm/shuvi-app/entry/server/index.d.ts +6 -0
  28. package/esm/shuvi-app/entry/server/index.js +7 -0
  29. package/esm/shuvi-app/react/AppComponent.d.ts +4 -0
  30. package/esm/shuvi-app/react/AppComponent.jsx +6 -0
  31. package/esm/shuvi-app/react/AppContainer.d.ts +6 -0
  32. package/esm/shuvi-app/react/AppContainer.jsx +23 -0
  33. package/esm/shuvi-app/react/Error.d.ts +5 -0
  34. package/esm/shuvi-app/react/Error.jsx +38 -0
  35. package/esm/shuvi-app/react/ErrorBoundary.d.ts +16 -0
  36. package/esm/shuvi-app/react/ErrorBoundary.jsx +25 -0
  37. package/esm/shuvi-app/react/ErrorPage.d.ts +5 -0
  38. package/esm/shuvi-app/react/ErrorPage.jsx +7 -0
  39. package/esm/shuvi-app/react/Link.d.ts +7 -0
  40. package/esm/shuvi-app/react/Link.jsx +115 -0
  41. package/esm/shuvi-app/react/applicationContext.d.ts +7 -0
  42. package/esm/shuvi-app/react/applicationContext.jsx +10 -0
  43. package/esm/shuvi-app/react/dynamic.d.ts +31 -0
  44. package/esm/shuvi-app/react/dynamic.jsx +62 -0
  45. package/esm/shuvi-app/react/getRoutes.d.ts +2 -0
  46. package/esm/shuvi-app/react/getRoutes.js +31 -0
  47. package/esm/shuvi-app/react/head/head-manager-context.d.ts +2 -0
  48. package/esm/shuvi-app/react/head/head-manager-context.js +2 -0
  49. package/esm/shuvi-app/react/head/head-manager.d.ts +10 -0
  50. package/esm/shuvi-app/react/head/head-manager.js +93 -0
  51. package/esm/shuvi-app/react/head/head.d.ts +33 -0
  52. package/esm/shuvi-app/react/head/head.jsx +178 -0
  53. package/esm/shuvi-app/react/head/index.d.ts +4 -0
  54. package/esm/shuvi-app/react/head/index.js +4 -0
  55. package/esm/shuvi-app/react/head/side-effect.d.ts +30 -0
  56. package/esm/shuvi-app/react/head/side-effect.jsx +44 -0
  57. package/esm/shuvi-app/react/head/types.d.ts +15 -0
  58. package/esm/shuvi-app/react/head/types.js +1 -0
  59. package/esm/shuvi-app/react/index.d.ts +4 -0
  60. package/esm/shuvi-app/react/index.js +4 -0
  61. package/esm/shuvi-app/react/loadRouteComponent.d.ts +4 -0
  62. package/esm/shuvi-app/react/loadRouteComponent.jsx +9 -0
  63. package/esm/shuvi-app/react/loadable/index.d.ts +2 -0
  64. package/esm/shuvi-app/react/loadable/index.js +2 -0
  65. package/esm/shuvi-app/react/loadable/loadable-context.d.ts +4 -0
  66. package/esm/shuvi-app/react/loadable/loadable-context.js +3 -0
  67. package/esm/shuvi-app/react/loadable/loadable.d.ts +30 -0
  68. package/esm/shuvi-app/react/loadable/loadable.js +277 -0
  69. package/esm/shuvi-app/react/shuvi-runtime-api.d.ts +5 -0
  70. package/esm/shuvi-app/react/shuvi-runtime-api.js +5 -0
  71. package/esm/shuvi-app/react/types.d.ts +14 -0
  72. package/esm/shuvi-app/react/types.js +1 -0
  73. package/esm/shuvi-app/react/useLoaderData.d.ts +2 -0
  74. package/esm/shuvi-app/react/useLoaderData.js +27 -0
  75. package/esm/shuvi-app/react/utils/getDisplayName.d.ts +2 -0
  76. package/esm/shuvi-app/react/utils/getDisplayName.js +3 -0
  77. package/esm/shuvi-app/react/utils/requestIdleCallback.d.ts +2 -0
  78. package/esm/shuvi-app/react/utils/requestIdleCallback.js +20 -0
  79. package/esm/shuvi-app/react/utils/useIntersection.d.ts +8 -0
  80. package/esm/shuvi-app/react/utils/useIntersection.jsx +91 -0
  81. package/esm/shuvi-app/react/view/ReactView.client.d.ts +5 -0
  82. package/esm/shuvi-app/react/view/ReactView.client.jsx +64 -0
  83. package/esm/shuvi-app/react/view/ReactView.server.d.ts +4 -0
  84. package/esm/shuvi-app/react/view/ReactView.server.jsx +109 -0
  85. package/esm/shuvi-app/react/view/clientView.d.ts +3 -0
  86. package/esm/shuvi-app/react/view/clientView.js +2 -0
  87. package/esm/shuvi-app/react/view/index.d.ts +2 -0
  88. package/esm/shuvi-app/react/view/index.js +7 -0
  89. package/esm/shuvi-app/react/view/render-action.d.ts +10 -0
  90. package/esm/shuvi-app/react/view/render-action.js +29 -0
  91. package/esm/shuvi-app/react/view/serverView.d.ts +3 -0
  92. package/esm/shuvi-app/react/view/serverView.js +2 -0
  93. package/esm/shuvi-app/react/view/transformRoutes.d.ts +2 -0
  94. package/esm/shuvi-app/react/view/transformRoutes.js +3 -0
  95. package/esm/shuvi-app/shuvi-runtime-index.d.ts +4 -0
  96. package/esm/shuvi-app/shuvi-runtime-index.js +2 -0
  97. package/esm/shuvi-app/shuvi-runtime-server.d.ts +6 -0
  98. package/esm/shuvi-app/shuvi-runtime-server.js +1 -0
  99. package/lib/node/features/custom-server/hooks.d.ts +9 -0
  100. package/lib/node/features/custom-server/hooks.js +13 -0
  101. package/lib/node/features/custom-server/index.d.ts +17 -0
  102. package/lib/node/features/custom-server/index.js +28 -0
  103. package/lib/node/features/custom-server/server.d.ts +2 -0
  104. package/lib/node/features/custom-server/server.js +32 -0
  105. package/lib/node/features/custom-server/shuvi-app.d.ts +11 -0
  106. package/lib/node/features/custom-server/shuvi-app.js +2 -0
  107. package/lib/node/features/filesystem-routes/api/apiRouteHandler.d.ts +50 -0
  108. package/lib/node/features/filesystem-routes/api/apiRouteHandler.js +237 -0
  109. package/lib/node/features/filesystem-routes/api/apiRoutes.d.ts +7 -0
  110. package/lib/node/features/filesystem-routes/api/apiRoutes.js +35 -0
  111. package/lib/node/features/filesystem-routes/api/index.d.ts +3 -0
  112. package/lib/node/features/filesystem-routes/api/index.js +7 -0
  113. package/lib/node/features/filesystem-routes/api/middleware.d.ts +2 -0
  114. package/lib/node/features/filesystem-routes/api/middleware.js +46 -0
  115. package/lib/node/features/filesystem-routes/hooks.d.ts +3 -0
  116. package/lib/node/features/filesystem-routes/hooks.js +6 -0
  117. package/lib/node/features/filesystem-routes/index.d.ts +20 -0
  118. package/lib/node/features/filesystem-routes/index.js +182 -0
  119. package/lib/node/features/filesystem-routes/middleware/index.d.ts +2 -0
  120. package/lib/node/features/filesystem-routes/middleware/index.js +7 -0
  121. package/lib/node/features/filesystem-routes/middleware/middleware.d.ts +2 -0
  122. package/lib/node/features/filesystem-routes/middleware/middleware.js +42 -0
  123. package/lib/node/features/filesystem-routes/middleware/routes.d.ts +9 -0
  124. package/lib/node/features/filesystem-routes/middleware/routes.js +34 -0
  125. package/lib/node/features/filesystem-routes/page/index.d.ts +2 -0
  126. package/lib/node/features/filesystem-routes/page/index.js +21 -0
  127. package/lib/node/features/filesystem-routes/page/routes.d.ts +8 -0
  128. package/lib/node/features/filesystem-routes/page/routes.js +83 -0
  129. package/lib/node/features/filesystem-routes/page/store.d.ts +3 -0
  130. package/lib/node/features/filesystem-routes/page/store.js +10 -0
  131. package/lib/node/features/filesystem-routes/shuvi-app.d.ts +7 -0
  132. package/lib/node/features/filesystem-routes/shuvi-app.js +2 -0
  133. package/lib/node/features/html-render/index.d.ts +16 -0
  134. package/lib/node/features/html-render/index.js +21 -0
  135. package/lib/node/features/html-render/lib/generateFilesByRoutId.d.ts +3 -0
  136. package/lib/node/features/html-render/lib/generateFilesByRoutId.js +13 -0
  137. package/lib/node/features/html-render/lib/getPageMiddleware.d.ts +2 -0
  138. package/lib/node/features/html-render/lib/getPageMiddleware.js +56 -0
  139. package/lib/node/features/html-render/lib/index.d.ts +4 -0
  140. package/lib/node/features/html-render/lib/index.js +23 -0
  141. package/lib/node/features/html-render/lib/pageLoader.d.ts +1 -0
  142. package/lib/node/features/html-render/lib/pageLoader.js +42 -0
  143. package/lib/node/features/html-render/lib/renderToHTML.d.ts +6 -0
  144. package/lib/node/features/html-render/lib/renderToHTML.js +81 -0
  145. package/lib/node/features/html-render/lib/renderer/base.d.ts +17 -0
  146. package/lib/node/features/html-render/lib/renderer/base.js +70 -0
  147. package/lib/node/features/html-render/lib/renderer/htmlTag.d.ts +4 -0
  148. package/lib/node/features/html-render/lib/renderer/htmlTag.js +70 -0
  149. package/lib/node/features/html-render/lib/renderer/index.d.ts +15 -0
  150. package/lib/node/features/html-render/lib/renderer/index.js +48 -0
  151. package/lib/node/features/html-render/lib/renderer/spa.d.ts +5 -0
  152. package/lib/node/features/html-render/lib/renderer/spa.js +26 -0
  153. package/lib/node/features/html-render/lib/renderer/ssr.d.ts +5 -0
  154. package/lib/node/features/html-render/lib/renderer/ssr.js +70 -0
  155. package/lib/node/features/html-render/lib/renderer/types.d.ts +20 -0
  156. package/lib/node/features/html-render/lib/renderer/types.js +2 -0
  157. package/lib/node/features/html-render/lib/viewTemplate.d.ts +5 -0
  158. package/lib/node/features/html-render/lib/viewTemplate.js +37 -0
  159. package/lib/node/features/index.d.ts +28 -0
  160. package/lib/node/features/index.js +25 -0
  161. package/lib/node/features/main/buildHtml.d.ts +8 -0
  162. package/lib/node/features/main/buildHtml.js +64 -0
  163. package/lib/node/features/main/generateResource.d.ts +3 -0
  164. package/lib/node/features/main/generateResource.js +58 -0
  165. package/lib/node/features/main/index.d.ts +3 -0
  166. package/lib/node/features/main/index.js +103 -0
  167. package/lib/node/features/middlewares.d.ts +4 -0
  168. package/lib/node/features/middlewares.js +22 -0
  169. package/lib/node/features/model/index.d.ts +20 -0
  170. package/lib/node/features/model/index.js +54 -0
  171. package/lib/node/features/model/runtime.d.ts +8 -0
  172. package/lib/node/features/model/runtime.js +47 -0
  173. package/lib/node/features/model/server.d.ts +3 -0
  174. package/lib/node/features/model/server.js +12 -0
  175. package/lib/node/features/model/shuvi-app.d.ts +6 -0
  176. package/lib/node/features/model/shuvi-app.js +2 -0
  177. package/lib/node/features/on-demand-compile-page/emptyComponent.d.ts +1 -0
  178. package/lib/node/features/on-demand-compile-page/emptyComponent.js +7 -0
  179. package/lib/node/features/on-demand-compile-page/index.d.ts +14 -0
  180. package/lib/node/features/on-demand-compile-page/index.js +36 -0
  181. package/lib/node/features/on-demand-compile-page/onDemandRouteManager.d.ts +11 -0
  182. package/lib/node/features/on-demand-compile-page/onDemandRouteManager.js +104 -0
  183. package/lib/node/index.d.ts +4 -0
  184. package/lib/node/index.js +39 -0
  185. package/lib/{paths.d.ts → node/paths.d.ts} +1 -2
  186. package/lib/node/paths.js +16 -0
  187. package/lib/node/shuvi-node-extensions.d.ts +17 -0
  188. package/lib/node/shuvi-node-extensions.js +2 -0
  189. package/lib/node/targets/react/bundler/index.d.ts +15 -0
  190. package/lib/node/targets/react/bundler/index.js +102 -0
  191. package/lib/node/targets/react/index.d.ts +30 -0
  192. package/lib/node/targets/react/index.js +28 -0
  193. package/lib/node/targets/react/redox-react/RedoxWrapper.d.ts +8 -0
  194. package/lib/node/targets/react/redox-react/RedoxWrapper.js +37 -0
  195. package/lib/node/targets/react/redox-react/index.d.ts +17 -0
  196. package/lib/node/targets/react/redox-react/index.js +50 -0
  197. package/lib/node/targets/react/redox-react/runtime.d.ts +2 -0
  198. package/lib/node/targets/react/redox-react/runtime.js +18 -0
  199. package/lib/shared/appTypes.d.ts +15 -0
  200. package/lib/shared/appTypes.js +2 -0
  201. package/lib/shared/index.d.ts +4 -0
  202. package/lib/shared/index.js +20 -0
  203. package/lib/shared/renderTypes.d.ts +44 -0
  204. package/lib/shared/renderTypes.js +2 -0
  205. package/lib/shared/routeTypes.d.ts +47 -0
  206. package/lib/shared/routeTypes.js +2 -0
  207. package/lib/shared/serverTypes.d.ts +6 -0
  208. package/lib/shared/serverTypes.js +2 -0
  209. package/package.json +71 -17
  210. package/shuvi-app-extensions.d.ts +36 -0
  211. package/lib/index.d.ts +0 -3
  212. package/lib/index.js +0 -44
  213. package/lib/paths.js +0 -7
  214. package/shuvi-app/application/client/create-application-factory.d.ts +0 -3
  215. package/shuvi-app/application/client/create-application-factory.js +0 -70
  216. package/shuvi-app/application/client/create-application-history-browser.d.ts +0 -1
  217. package/shuvi-app/application/client/create-application-history-browser.js +0 -3
  218. package/shuvi-app/application/client/create-application-history-hash.d.ts +0 -1
  219. package/shuvi-app/application/client/create-application-history-hash.js +0 -3
  220. package/shuvi-app/application/client/create-application-history-memory.d.ts +0 -1
  221. package/shuvi-app/application/client/create-application-history-memory.js +0 -3
  222. package/shuvi-app/application/server/create-application-spa.d.ts +0 -2
  223. package/shuvi-app/application/server/create-application-spa.js +0 -8
  224. package/shuvi-app/application/server/create-application.d.ts +0 -2
  225. package/shuvi-app/application/server/create-application.js +0 -25
  226. package/shuvi-app/entry/client/index.d.ts +0 -1
  227. package/shuvi-app/entry/client/index.js +0 -11
  228. package/shuvi-app/entry/client/run.prod.js +0 -3
  229. package/shuvi-app/entry/client/setup-app.d.ts +0 -3
  230. package/shuvi-app/entry/client/setup-app.js +0 -38
  231. package/shuvi-app/entry/client/setup-env.js +0 -27
  232. package/shuvi-app/entry/server/index.d.ts +0 -6
  233. package/shuvi-app/entry/server/index.js +0 -7
@@ -0,0 +1,47 @@
1
+ import { IURLParams, IURLQuery } from '@shuvi/platform-shared/shared';
2
+ import { IRequestHandlerWithNext } from '@shuvi/service';
3
+ import { IResponse, IRequest } from '@shuvi/service';
4
+ export interface IApiReq {
5
+ pathname: string;
6
+ query: IURLQuery;
7
+ params: IURLParams;
8
+ cookies: {
9
+ [key: string]: string;
10
+ };
11
+ body?: {
12
+ [key: string]: any;
13
+ };
14
+ }
15
+ export declare type IApiRequest = IRequest & IApiReq;
16
+ export declare type Send<T> = (body: T) => void;
17
+ export declare type IApiRes<T = any> = {
18
+ send: Send<T>;
19
+ json: Send<T>;
20
+ status: (statusCode: number) => IApiRes<T>;
21
+ redirect(url: string): IApiRes<T>;
22
+ redirect(status: number, url: string): IApiRes<T>;
23
+ };
24
+ export declare type IApiResponse<T = any> = IResponse & IApiRes<T>;
25
+ export declare type IApiRequestHandler<T = any> = (req: IApiRequest, res: IApiResponse<T>) => void | Promise<void>;
26
+ export interface IApiConfig {
27
+ apiConfig?: {
28
+ bodyParser?: {
29
+ sizeLimit: number | string;
30
+ } | boolean;
31
+ };
32
+ }
33
+ export interface IApiHandler {
34
+ default: IApiRequestHandler;
35
+ config?: IApiConfig;
36
+ }
37
+ export interface IMiddlewareConfig {
38
+ default: IRequestHandlerWithNext;
39
+ }
40
+ export declare type IApiRoutes = {
41
+ path: string;
42
+ api: IApiHandler;
43
+ }[];
44
+ export declare type IMiddlewareRoutes = {
45
+ path: string;
46
+ middleware: IMiddlewareConfig;
47
+ }[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { ServerPluginConstructor } from '@shuvi/service';
2
+ export interface IServerModule {
3
+ getPageData?: ServerPluginConstructor['getPageData'];
4
+ handlePageRequest?: ServerPluginConstructor['handlePageRequest'];
5
+ modifyHtml?: ServerPluginConstructor['modifyHtml'];
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/platform-web",
3
- "version": "0.0.1-rc.32",
3
+ "version": "1.0.0-rc.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -11,28 +11,82 @@
11
11
  "sideEffects": [
12
12
  "**/shuvi-app/entry/client/**"
13
13
  ],
14
- "main": "./lib/index.js",
15
- "module": "./es/index.js",
16
14
  "files": [
17
15
  "lib",
18
- "shuvi-app"
16
+ "esm",
17
+ "types",
18
+ "shuvi-app-extensions.d.ts"
19
19
  ],
20
- "scripts": {
21
- "dev": "run-p watch:*",
22
- "watch:app": "tsc -p tsconfig.build.app.json -w",
23
- "watch:node": "tsc -p tsconfig.build.node.json -w",
24
- "prebuild": "rimraf lib shuvi-app",
25
- "build": "run-p build:*",
26
- "build:app": "tsc -p tsconfig.build.app.json",
27
- "build:node": "tsc -p tsconfig.build.node.json"
20
+ "exports": {
21
+ ".": {
22
+ "default": "./lib/node/index.js"
23
+ },
24
+ "./node": {
25
+ "default": "./lib/node/index.js"
26
+ },
27
+ "./node/*": {
28
+ "default": "./lib/node/*.js"
29
+ },
30
+ "./shared": {
31
+ "default": "./esm/shared/index.js"
32
+ },
33
+ "./shared/*": {
34
+ "default": "./esm/shared/*.js"
35
+ },
36
+ "./shuvi-app": {
37
+ "default": "./esm/shuvi-app/index.js"
38
+ },
39
+ "./shuvi-app/*": {
40
+ "default": [
41
+ "./esm/shuvi-app/*.js",
42
+ "./esm/shuvi-app/*.jsx"
43
+ ]
44
+ },
45
+ "./shuvi-app-extensions.d.ts": "./shuvi-app-extensions.d.ts"
28
46
  },
29
47
  "engines": {
30
48
  "node": ">= 12.0.0"
31
49
  },
32
50
  "dependencies": {
33
- "@shuvi/app": "^0.0.1-rc.32",
34
- "@shuvi/platform-core": "^0.0.1-rc.32",
35
- "@shuvi/service": "^0.0.1-rc.32",
36
- "@shuvi/shared": "^0.0.1-rc.32"
51
+ "@next/react-refresh-utils": "12.1.6",
52
+ "@shuvi/hook": "1.0.0-rc.0",
53
+ "@shuvi/platform-shared": "1.0.0-rc.0",
54
+ "@shuvi/redox-react": "0.0.3",
55
+ "@shuvi/router": "1.0.0-rc.0",
56
+ "@shuvi/router-react": "1.0.0-rc.0",
57
+ "@shuvi/runtime": "1.0.0-rc.0",
58
+ "@shuvi/service": "1.0.0-rc.0",
59
+ "@shuvi/shared": "1.0.0-rc.0",
60
+ "@shuvi/toolpack": "1.0.0-rc.0",
61
+ "@shuvi/utils": "1.0.0-rc.0",
62
+ "content-type": "1.0.4",
63
+ "cookie": "0.4.1",
64
+ "ejs": "3.1.5",
65
+ "fs-extra": "9.0.1",
66
+ "node-mocks-http": "1.11.0",
67
+ "raw-body": "2.4.1",
68
+ "react": "18.1.0",
69
+ "react-app-polyfill": "2.0.0",
70
+ "react-dom": "18.1.0",
71
+ "react-refresh": "0.12.0",
72
+ "use-sync-external-store": "1.1.0"
73
+ },
74
+ "devDependencies": {
75
+ "@shuvi/redox": "0.0.3",
76
+ "@testing-library/react": "^10.0.2",
77
+ "@types/content-type": "^1.1.5",
78
+ "@types/cookie": "^0.4.1",
79
+ "@types/ejs": "^3.1.0",
80
+ "@types/raw-body": "^2.3.0",
81
+ "webpack": "5.73.0"
82
+ },
83
+ "scripts": {
84
+ "dev": "run-p watch:*",
85
+ "watch:esm": "tsc -p tsconfig.build.browser.json -w",
86
+ "watch:cjs": "tsc -p tsconfig.build.node.json -w",
87
+ "prebuild": "rimraf lib esm types",
88
+ "build": "run-p build:*",
89
+ "build:esm": "tsc -p tsconfig.build.browser.json",
90
+ "build:cjs": "tsc -p tsconfig.build.node.json"
37
91
  }
38
- }
92
+ }
@@ -0,0 +1,36 @@
1
+ /// <reference types="@shuvi/platform-shared/shuvi-app-extensions.d.ts" />
2
+
3
+ declare module '@shuvi/app/files/routes' {
4
+ import { IRawPageRouteRecord } from '@shuvi/platform-shared/shared';
5
+ declare const routes: IRawPageRouteRecord[];
6
+ export default routes;
7
+ }
8
+
9
+ declare module '@shuvi/app/files/routerConfig' {
10
+ import { ILoaderOptions } from '@shuvi/platform-shared/shared/loader';
11
+ export const historyMode: 'browser' | 'hash';
12
+ }
13
+
14
+ declare module '@shuvi/app/files/page-loaders' {
15
+ import { IRouteLoaderContext } from '@shuvi/platform-shared/shared';
16
+ import { Loader } from '@shuvi/platform-shared/shared';
17
+
18
+ const loaders: Record<string, Loader>;
19
+ export default loaders;
20
+ }
21
+
22
+ declare module '@shuvi/app/files/apiRoutes' {
23
+ import { IApiRoutes } from '@shuvi/platform-web/shared';
24
+ declare const apiRoutes: IApiRoutes[];
25
+ export default apiRoutes;
26
+ }
27
+
28
+ declare module '@shuvi/app/files/middlewareRoutes' {
29
+ import { IMiddlewareRoutes } from '@shuvi/platform-web/shared';
30
+ declare const middlewareRoutes: IMiddlewareRoutes[];
31
+ export default middlewareRoutes;
32
+ }
33
+
34
+ declare module '@shuvi/app/files/user/server' {
35
+ export {};
36
+ }
package/lib/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { Runtime } from '@shuvi/service';
2
- declare const platform: Runtime.IRuntime<any>;
3
- export default platform;
package/lib/index.js DELETED
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const paths_1 = require("./paths");
13
- const platform = {
14
- install(api) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- // set application and entry
17
- const { ssr, router: { history } } = api.config;
18
- let ApplicationModule;
19
- if (history === 'browser') {
20
- ApplicationModule = 'create-application-history-browser';
21
- }
22
- else if (history === 'hash') {
23
- ApplicationModule = 'create-application-history-hash';
24
- }
25
- else {
26
- ApplicationModule = 'create-application-history-memory';
27
- }
28
- api.setServerModule({
29
- application: paths_1.resolveAppFile('application', 'server', ssr ? 'create-application' : 'create-application-spa'),
30
- entry: paths_1.resolveAppFile('entry', 'server')
31
- });
32
- api.setClientModule({
33
- application: paths_1.resolveAppFile('application', 'client', ApplicationModule),
34
- entry: paths_1.resolveAppFile('entry', 'client')
35
- });
36
- // install framework
37
- const { framework = 'react' } = api.config.platform || {};
38
- const frameworkInstance = require(`@shuvi/platform-web-${framework}`)
39
- .default;
40
- frameworkInstance.install(api);
41
- });
42
- }
43
- };
44
- exports.default = platform;
package/lib/paths.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path_1 = require("path");
4
- exports.PACKAGE_DIR = path_1.dirname(require.resolve('@shuvi/platform-web/package.json'));
5
- exports.resolveAppFile = (...paths) => `${path_1.resolve(exports.PACKAGE_DIR, 'shuvi-app', ...paths)}`;
6
- exports.resolveDep = (module) => require.resolve(module);
7
- exports.resolveLib = (module) => path_1.dirname(exports.resolveDep(path_1.join(module, 'package.json')));
@@ -1,3 +0,0 @@
1
- import { History } from '@shuvi/router/lib/types';
2
- import { Runtime } from '@shuvi/service';
3
- export declare const createFactory: (historyCreater: () => History) => Runtime.ApplicationCreater;
@@ -1,70 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import AppComponent from '@shuvi/app/core/app';
11
- import routes from '@shuvi/app/core/routes';
12
- import { getRoutes } from '@shuvi/app/core/platform';
13
- import { Application } from '@shuvi/platform-core';
14
- import runPlugins from '@shuvi/platform-core/lib/runPlugins';
15
- import { createRouter } from '@shuvi/router';
16
- let app;
17
- let history;
18
- let appContext;
19
- export const createFactory = (historyCreater) => {
20
- const create = function (context, options) {
21
- appContext = context;
22
- // app is a singleton in client side
23
- if (app) {
24
- return app;
25
- }
26
- history = historyCreater();
27
- const router = createRouter({
28
- history,
29
- routes: getRoutes(routes, context)
30
- });
31
- app = new Application({
32
- AppComponent,
33
- router,
34
- context,
35
- render: options.render
36
- });
37
- runPlugins(app);
38
- return app;
39
- };
40
- return create;
41
- };
42
- if (module.hot) {
43
- module.hot.accept([
44
- '@shuvi/app/entry.client',
45
- '@shuvi/app/core/app',
46
- '@shuvi/app/core/routes',
47
- '@shuvi/app/user/plugin'
48
- ], () => __awaiter(void 0, void 0, void 0, function* () {
49
- const rerender = () => {
50
- const AppComponent = require('@shuvi/app/core/app').default;
51
- const routes = require('@shuvi/app/core/routes').default;
52
- const router = createRouter({
53
- history,
54
- routes: getRoutes(routes, appContext)
55
- });
56
- app.rerender({ router, AppComponent });
57
- };
58
- // to solve routing problem, we need to rerender routes
59
- // wait navigation complete only rerender to ensure getInitialProps is called
60
- if (__SHUVI.router._pending) {
61
- const removelistener = __SHUVI.router.afterEach(() => {
62
- rerender();
63
- removelistener();
64
- });
65
- }
66
- else {
67
- rerender();
68
- }
69
- }));
70
- }
@@ -1 +0,0 @@
1
- export declare const create: import("@shuvi/service/lib/types/runtime").ApplicationCreater;
@@ -1,3 +0,0 @@
1
- import { createFactory } from './create-application-factory';
2
- import { createBrowserHistory } from '@shuvi/router';
3
- export const create = createFactory(createBrowserHistory);
@@ -1 +0,0 @@
1
- export declare const create: import("@shuvi/service/lib/types/runtime").ApplicationCreater;
@@ -1,3 +0,0 @@
1
- import { createFactory } from './create-application-factory';
2
- import { createHashHistory } from '@shuvi/router';
3
- export const create = createFactory(createHashHistory);
@@ -1 +0,0 @@
1
- export declare const create: import("@shuvi/service/lib/types/runtime").ApplicationCreater;
@@ -1,3 +0,0 @@
1
- import { createFactory } from './create-application-factory';
2
- import { createMemoryHistory } from '@shuvi/router';
3
- export const create = createFactory(createMemoryHistory);
@@ -1,2 +0,0 @@
1
- import { Runtime } from '@shuvi/service';
2
- export declare const create: Runtime.ApplicationCreater;
@@ -1,8 +0,0 @@
1
- import { Application } from '@shuvi/platform-core';
2
- export const create = function (context, options) {
3
- return new Application({
4
- AppComponent: null,
5
- context,
6
- render: options.render
7
- });
8
- };
@@ -1,2 +0,0 @@
1
- import { Runtime } from '@shuvi/service';
2
- export declare const create: Runtime.ApplicationCreater;
@@ -1,25 +0,0 @@
1
- import AppComponent from '@shuvi/app/core/app';
2
- import routes from '@shuvi/app/core/routes';
3
- import { getRoutes } from '@shuvi/app/core/platform';
4
- import { Application } from '@shuvi/platform-core';
5
- import runPlugins from '@shuvi/platform-core/lib/runPlugins';
6
- import { createRouter, createMemoryHistory } from '@shuvi/router';
7
- export const create = function (context, options) {
8
- const { req } = context;
9
- const history = createMemoryHistory({
10
- initialEntries: [(req && req.url) || '/'],
11
- initialIndex: 0
12
- });
13
- const router = createRouter({
14
- history,
15
- routes: getRoutes(routes, context)
16
- });
17
- const app = new Application({
18
- AppComponent,
19
- router,
20
- context,
21
- render: options.render
22
- });
23
- runPlugins(app);
24
- return app;
25
- };
@@ -1 +0,0 @@
1
- import './setup-env';
@@ -1,11 +0,0 @@
1
- // This is the shuvi client-side entry
2
- // IMPORTANT: `setup-env` must be runned before any other codes
3
- import './setup-env';
4
- import { rerender } from './setup-app';
5
- window.__SHUVI = Object.assign(Object.assign({}, (window.__SHUVI || {})), { rerender });
6
- if (process.env.NODE_ENV === 'development') {
7
- require('./run.dev');
8
- }
9
- else {
10
- require('./run.prod');
11
- }
@@ -1,3 +0,0 @@
1
- /// <reference lib="dom" />
2
- import { app } from './setup-app';
3
- app.run();
@@ -1,3 +0,0 @@
1
- declare const app: import("@shuvi/runtime-core").IApplication;
2
- declare const rerender: () => void;
3
- export { app, rerender };
@@ -1,38 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { CLIENT_CONTAINER_ID } from '@shuvi/shared/lib/constants';
11
- // renderer must be imported before application
12
- // we need to init init renderer before import AppComponent
13
- import { view } from '@shuvi/app/core/platform';
14
- import { create } from '@shuvi/app/core/client/application';
15
- import { getAppData } from '@shuvi/platform-core/lib/helper';
16
- const appData = getAppData();
17
- const { routeProps = {} } = appData;
18
- const app = create({
19
- pageData: appData.pageData || {},
20
- routeProps
21
- }, {
22
- render({ appContext, AppComponent, router }) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const appContainer = document.getElementById(CLIENT_CONTAINER_ID);
25
- view.renderApp({
26
- AppComponent: AppComponent,
27
- router: router,
28
- appData,
29
- appContainer,
30
- appContext
31
- });
32
- });
33
- }
34
- });
35
- const rerender = () => {
36
- app.rerender();
37
- };
38
- export { app, rerender };
@@ -1,27 +0,0 @@
1
- /**
2
- * Following codes should be run beforen any other codes.
3
- * Do not try to import any module from `@shuvi/app`.
4
- */
5
- import { IDENTITY_RUNTIME_PUBLICPATH, IDENTITY_SSR_RUNTIME_PUBLICPATH } from '@shuvi/shared/lib/constants';
6
- import setRuntimeConfig from '@shuvi/app/core/setRuntimeConfig';
7
- import runtimeConfig from '@shuvi/app/core/runtimeConfig';
8
- import { getAppData } from '@shuvi/platform-core/lib/helper';
9
- const win = window;
10
- // server runtime public path
11
- if (win[IDENTITY_SSR_RUNTIME_PUBLICPATH]) {
12
- __webpack_public_path__ = win[IDENTITY_SSR_RUNTIME_PUBLICPATH];
13
- }
14
- // client runtime public path
15
- if (win[IDENTITY_RUNTIME_PUBLICPATH]) {
16
- __webpack_public_path__ = win[IDENTITY_RUNTIME_PUBLICPATH];
17
- }
18
- // === set runtime config ===
19
- const appData = getAppData();
20
- // build-time config for none-ssr
21
- if (runtimeConfig) {
22
- setRuntimeConfig(runtimeConfig);
23
- }
24
- // runtime config from server
25
- if (appData.runtimeConfig) {
26
- setRuntimeConfig(appData.runtimeConfig);
27
- }
@@ -1,6 +0,0 @@
1
- import * as server from '@shuvi/app/user/server';
2
- import * as document from '@shuvi/app/user/document';
3
- import * as application from '@shuvi/app/core/server/application';
4
- import { default as apiRoutes } from '@shuvi/app/core/apiRoutes';
5
- export { server, document, application, apiRoutes };
6
- export { view } from '@shuvi/app/core/platform';
@@ -1,7 +0,0 @@
1
- // This is the shuvi server-side main module exports collection
2
- import * as server from '@shuvi/app/user/server';
3
- import * as document from '@shuvi/app/user/document';
4
- import * as application from '@shuvi/app/core/server/application';
5
- import { default as apiRoutes } from '@shuvi/app/core/apiRoutes';
6
- export { server, document, application, apiRoutes };
7
- export { view } from '@shuvi/app/core/platform';