proteum 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/cli/app/config.ts +54 -0
  2. package/cli/app/index.ts +195 -0
  3. package/cli/bin.js +35 -0
  4. package/cli/commands/build.ts +34 -0
  5. package/cli/commands/deploy/app.ts +29 -0
  6. package/cli/commands/deploy/web.ts +60 -0
  7. package/cli/commands/dev.ts +109 -0
  8. package/cli/commands/init.ts +85 -0
  9. package/cli/compiler/client/identite.ts +72 -0
  10. package/cli/compiler/client/index.ts +335 -0
  11. package/cli/compiler/common/babel/index.ts +170 -0
  12. package/cli/compiler/common/babel/plugins/index.ts +0 -0
  13. package/cli/compiler/common/babel/plugins/services.ts +586 -0
  14. package/cli/compiler/common/babel/routes/imports.ts +127 -0
  15. package/cli/compiler/common/babel/routes/routes.ts +1130 -0
  16. package/cli/compiler/common/files/autres.ts +39 -0
  17. package/cli/compiler/common/files/images.ts +42 -0
  18. package/cli/compiler/common/files/style.ts +80 -0
  19. package/cli/compiler/common/index.ts +160 -0
  20. package/cli/compiler/index.ts +564 -0
  21. package/cli/compiler/server/index.ts +211 -0
  22. package/cli/index.ts +189 -0
  23. package/cli/paths.ts +165 -0
  24. package/cli/print.ts +12 -0
  25. package/cli/tsconfig.json +42 -0
  26. package/cli/utils/index.ts +22 -0
  27. package/cli/utils/keyboard.ts +78 -0
  28. package/client/app/index.ts +2 -0
  29. package/client/components/Dialog/Manager.tsx +3 -49
  30. package/client/components/Dialog/index.less +3 -1
  31. package/client/components/index.ts +1 -2
  32. package/client/services/router/index.tsx +6 -16
  33. package/common/errors/index.tsx +12 -31
  34. package/doc/TODO.md +1 -1
  35. package/package.json +58 -20
  36. package/server/app/container/console/index.ts +1 -1
  37. package/server/services/auth/index.ts +62 -27
  38. package/server/services/auth/router/request.ts +17 -6
  39. package/server/services/router/http/index.ts +1 -1
  40. package/server/services/router/response/index.ts +1 -1
  41. package/server/services/schema/request.ts +28 -10
  42. package/tsconfig.common.json +2 -1
  43. package/changelog.md +0 -5
  44. package/client/components/Button.tsx +0 -298
  45. package/client/components/Dialog/card.tsx +0 -208
  46. package/client/data/input.ts +0 -32
  47. package/client/pages/bug.tsx.old +0 -60
  48. package/templates/composant.tsx +0 -40
  49. package/templates/form.ts +0 -30
  50. package/templates/modal.tsx +0 -47
  51. package/templates/modele.ts +0 -56
  52. package/templates/page.tsx +0 -74
  53. package/templates/route.ts +0 -43
  54. package/templates/service.ts +0 -75
  55. package/vscode/copyimportationpath/.eslintrc.json +0 -24
  56. package/vscode/copyimportationpath/.vscodeignore +0 -12
  57. package/vscode/copyimportationpath/CHANGELOG.md +0 -9
  58. package/vscode/copyimportationpath/README.md +0 -3
  59. package/vscode/copyimportationpath/copyimportationpath-0.0.1.vsix +0 -0
  60. package/vscode/copyimportationpath/out/extension.js +0 -206
  61. package/vscode/copyimportationpath/out/extension.js.map +0 -1
  62. package/vscode/copyimportationpath/package-lock.json +0 -4536
  63. package/vscode/copyimportationpath/package.json +0 -86
  64. package/vscode/copyimportationpath/src/extension.ts +0 -300
  65. package/vscode/copyimportationpath/tsconfig.json +0 -22
  66. package/vscode/copyimportationpath/vsc-extension-quickstart.md +0 -42
@@ -0,0 +1,127 @@
1
+ /*----------------------------------
2
+ - DEPENDANCES
3
+ ----------------------------------*/
4
+
5
+ // Npm
6
+ import type { ImportTransformer } from 'babel-plugin-glob-import';
7
+ import * as types from '@babel/types'
8
+ import path from 'path';
9
+ import generate from '@babel/generator';
10
+
11
+ // Core
12
+ import cli from '@cli';
13
+ import type { TAppSide, default as App } from '@cli/app';
14
+
15
+ // Resources
16
+ const routesToPreload = require( cli.paths.appRoot + '/client/pages/preload.json' );
17
+
18
+ /*----------------------------------
19
+ - CONFIG
20
+ ----------------------------------*/
21
+
22
+ const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
23
+
24
+ /*----------------------------------
25
+ - TRANSFORMER
26
+ ----------------------------------*/
27
+
28
+ module.exports = (app: App, side: TAppSide, dev: boolean): ImportTransformer => ({
29
+
30
+ debug: false,
31
+
32
+ test: (request) => (
33
+ side === 'client'
34
+ &&
35
+ (
36
+ request.source === '@client/pages/**/([a-z0-9]*).tsx'
37
+ ||
38
+ request.source === '@/client/pages/**/([a-z0-9]*).tsx'
39
+ )
40
+ &&
41
+ request.type === 'import'
42
+ ),
43
+ replace: (request, matches, t) => {
44
+
45
+ if (request.imported.type !== 'all')
46
+ return;
47
+
48
+ const imports: types.ImportDeclaration[] = [];
49
+
50
+ // const routes = {
51
+ // <chunkId1>: () => import(/* webpackChunkName: '<chunkId>' */ "<file>"),
52
+ // <chunkId2>: () => require("<file>").default,
53
+ // }
54
+
55
+ const pageLoaders: types.ObjectProperty[] = [];
56
+ for (const file of matches) {
57
+
58
+ // Exclude layouts
59
+ if (file.filename.includes("/_layout/")) {
60
+ //console.log("Exclude", file, 'from pages loaders (its a layout)');
61
+ continue;
62
+ }
63
+
64
+ // Page config
65
+ const { chunkId } = cli.paths.getPageChunk(app, file.filename);
66
+ const preloadPage = routesToPreload.includes(chunkId);
67
+
68
+ // Preload = use sync import
69
+ if (preloadPage) {
70
+
71
+ // import <chunkId> from "<file>";
72
+ imports.push(
73
+ t.importDeclaration(
74
+ [t.importSpecifier(
75
+ t.identifier(chunkId),
76
+ t.identifier('__register'),
77
+ )],
78
+ t.stringLiteral(file.filename)
79
+ )
80
+ );
81
+
82
+ // { <chunkId>: <chunkId> }
83
+ pageLoaders.push(
84
+ t.objectProperty(
85
+ t.stringLiteral(chunkId),
86
+ t.identifier(chunkId)
87
+ )
88
+ );
89
+
90
+ // Otherwise, use async import + chunk name
91
+ } else {
92
+
93
+ // <chunkId>: () => ...
94
+ pageLoaders.push(
95
+ t.objectProperty(
96
+
97
+ t.stringLiteral(chunkId),
98
+ // () => import(/* webpackChunkName: '<chunkId>' */ "<file>")
99
+ t.arrowFunctionExpression([], t.callExpression(
100
+
101
+ t.import(), [t.addComment(
102
+ t.stringLiteral(file.filename),
103
+ "leading",
104
+ "webpackChunkName: '" + chunkId + "'"
105
+ )]
106
+ ))
107
+ )
108
+ )
109
+ }
110
+ }
111
+
112
+ /*console.log( generate(t.variableDeclaration("const", [t.variableDeclarator(
113
+ t.identifier(request.imported.name),
114
+ t.objectExpression(pageLoaders)
115
+ )])).code );*/
116
+
117
+ return [
118
+ ...imports,
119
+ // const routes = { ... }
120
+ t.variableDeclaration("const", [t.variableDeclarator(
121
+ t.identifier(request.imported.name),
122
+ t.objectExpression(pageLoaders)
123
+ )])
124
+ ]
125
+
126
+ }
127
+ })