5htp 0.4.6 → 0.5.9-4

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 (41) hide show
  1. package/{src/app → app}/config.ts +7 -7
  2. package/app/index.ts +190 -0
  3. package/{src/commands → commands}/dev.ts +2 -2
  4. package/{src/commands → commands}/init.ts +1 -1
  5. package/{src/compiler → compiler}/client/identite.ts +1 -1
  6. package/{src/compiler → compiler}/client/index.ts +6 -6
  7. package/{src/compiler → compiler}/common/babel/index.ts +20 -2
  8. package/{src/compiler → compiler}/common/babel/plugins/injection-dependances/index.ts +5 -3
  9. package/{src/compiler → compiler}/common/babel/plugins/queries/index.ts +1 -1
  10. package/compiler/common/babel/plugins/services.ts +245 -0
  11. package/{src/compiler → compiler}/common/babel/routes/imports.ts +3 -3
  12. package/{src/compiler → compiler}/common/babel/routes/routes.ts +218 -70
  13. package/{src/compiler → compiler}/common/files/style.ts +3 -3
  14. package/{src/compiler → compiler}/common/plugins/indexage/icones-svg/index.ts +2 -2
  15. package/{src/compiler → compiler}/index.ts +179 -48
  16. package/{src/compiler → compiler}/server/index.ts +18 -11
  17. package/package.json +7 -5
  18. package/{src/paths.ts → paths.ts} +3 -4
  19. package/tsconfig.json +3 -2
  20. package/src/app/index.ts +0 -111
  21. package/src/compiler/common/babel/plugins/services.ts +0 -209
  22. /package/{src/commands → commands}/build.ts +0 -0
  23. /package/{src/commands → commands}/deploy/app.ts +0 -0
  24. /package/{src/commands → commands}/deploy/web.ts +0 -0
  25. /package/{src/compiler → compiler}/common/babel/plugins/form.ts +0 -0
  26. /package/{src/compiler → compiler}/common/babel/plugins/icones-svg.ts +0 -0
  27. /package/{src/compiler → compiler}/common/babel/plugins/index.ts +0 -0
  28. /package/{src/compiler → compiler}/common/babel/plugins/injection-dependances/remplacerFonction.ts +0 -0
  29. /package/{src/compiler → compiler}/common/files/autres.ts +0 -0
  30. /package/{src/compiler → compiler}/common/files/images.ts +0 -0
  31. /package/{src/compiler → compiler}/common/index.ts +0 -0
  32. /package/{src/compiler → compiler}/common/plugins/indexage/_utils/Stringify.ts +0 -0
  33. /package/{src/compiler → compiler}/common/plugins/indexage/_utils/annotations.ts +0 -0
  34. /package/{src/compiler → compiler}/common/plugins/indexage/_utils/iterateur.ts +0 -0
  35. /package/{src/compiler → compiler}/common/plugins/indexage/index.ts +0 -0
  36. /package/{src/compiler → compiler}/common/plugins/indexage/indexeur.ts +0 -0
  37. /package/{src/compiler → compiler}/common/plugins/indexage/injection-dependances/index.ts +0 -0
  38. /package/{src/index.ts → index.ts} +0 -0
  39. /package/{src/print.ts → print.ts} +0 -0
  40. /package/{src/utils → utils}/index.ts +0 -0
  41. /package/{src/utils → utils}/keyboard.ts +0 -0
@@ -1,209 +0,0 @@
1
- /*----------------------------------
2
- - DEPENDANCES
3
- ----------------------------------*/
4
-
5
- // Npm
6
- import * as types from '@babel/types'
7
- import type { PluginObj } from '@babel/core';
8
-
9
- // Core
10
- import cli from '@cli';
11
- import { App, TAppSide } from '../../../../app';
12
-
13
- /*----------------------------------
14
- - WEBPACK RULE
15
- ----------------------------------*/
16
-
17
- type TOptions = {
18
- side: TAppSide,
19
- app: App,
20
- debug?: boolean
21
- }
22
-
23
- type TImportSource = 'container' | 'application';
24
-
25
- module.exports = (options: TOptions) => (
26
- [Plugin, options]
27
- )
28
-
29
-
30
- /*----------------------------------
31
- - PLUGIN
32
- ----------------------------------*/
33
- function Plugin(babel, { app, side, debug }: TOptions) {
34
-
35
- const t = babel.types as typeof types;
36
-
37
- /*
38
- Transforms:
39
- import { MyService, Environment } from '@app';
40
- ...
41
- MyService.method()
42
- Environment.name
43
-
44
- To:
45
- import app from '@app';
46
- import Container from '@server/app/container';
47
- ...
48
- app.services.MyService.method()
49
- Container.Environment.name
50
-
51
- Processed files:
52
- @/server/config
53
- @/server/routes
54
- @/server/services
55
- */
56
-
57
- const plugin: PluginObj<{
58
-
59
- debug: boolean,
60
-
61
- filename: string,
62
- processFile: boolean,
63
-
64
- // Identifier => Name
65
- importedServicesCount: number,
66
- importedServices: {
67
- [local: string]: {
68
- imported: string,
69
- bindings: any, // TODO: Scope.Binding[] type
70
- source: TImportSource
71
- }
72
- },
73
- bySource: {[importSource in TImportSource] : number}
74
- }> = {
75
- pre(state) {
76
-
77
- this.filename = state.opts.filename as string;
78
- this.processFile = (
79
- this.filename.startsWith( cli.paths.appRoot + '/src/server/config' )
80
- ||
81
- this.filename.startsWith( cli.paths.appRoot + '/src/server/routes' )
82
- ||
83
- this.filename.startsWith( cli.paths.appRoot + '/src/server/services' )
84
- )
85
-
86
- this.importedServices = {}
87
- this.bySource = {
88
- container: 0,
89
- application: 0
90
- }
91
- this.importedServicesCount = 0
92
- this.debug = debug || false;
93
-
94
- },
95
- visitor: {
96
-
97
- // Find @app imports
98
- // Test: import { router } from '@app';
99
- // Replace by: nothing
100
- ImportDeclaration(path) {
101
-
102
- if (!this.processFile)
103
- return;
104
-
105
- if (path.node.source.value !== '@app')
106
- return;
107
-
108
- for (const specifier of path.node.specifiers) {
109
-
110
- if (specifier.type !== 'ImportSpecifier')
111
- continue;
112
-
113
- if (specifier.imported.type !== 'Identifier')
114
- continue;
115
-
116
- this.importedServicesCount++;
117
-
118
- let importSource: TImportSource;
119
- if (app.containerServices.includes(specifier.imported.name))
120
- importSource = 'container';
121
- else
122
- importSource = 'application';
123
-
124
- this.importedServices[ specifier.local.name ] = {
125
- imported: specifier.imported.name,
126
- bindings: path.scope.bindings[ specifier.local.name ].referencePaths,
127
- source: importSource
128
- }
129
-
130
- this.bySource[ importSource ]++;
131
- }
132
-
133
- // Replace by simple import
134
- this.debug && console.log("[babel][services] Replace importation");
135
- const replaceWith: any[] = []
136
-
137
- if (this.bySource.container > 0)
138
- replaceWith.push(
139
- t.importDeclaration(
140
- [t.importDefaultSpecifier( t.identifier('container') )],
141
- t.stringLiteral( cli.paths.core.src + '/server/app/container')
142
- )
143
- );
144
-
145
- // NOTE: Update 20/07: services should be accessed through current service instance
146
- /*if (this.bySource.application > 0)
147
- replaceWith.push(
148
- t.importDeclaration(
149
- [t.importDefaultSpecifier( t.identifier('application') )],
150
- t.stringLiteral( cli.paths.core.src + '/server/app/instance')
151
- )
152
- );*/
153
-
154
- path.replaceWithMultiple(replaceWith);
155
- },
156
-
157
- Identifier(path) {
158
-
159
- if (!this.processFile || this.importedServicesCount === 0)
160
- return;
161
-
162
- // Get service the identifier makes rfeerence to
163
- const name = path.node.name;
164
- const service = this.importedServices[ name ];
165
- if (service === undefined)
166
- return;
167
-
168
- // sometimes not iterable
169
- if (!service.bindings)
170
- return;
171
-
172
- // Replace by app.services.name
173
- let serviceBinding: any;
174
- for (const binding of service.bindings) {
175
- if (binding.replaced !== true && path.getPathLocation() === binding.getPathLocation()) {
176
-
177
- serviceBinding = binding;
178
-
179
- break;
180
- }
181
- }
182
-
183
- // This identifier is a binding to a service
184
- if (serviceBinding === undefined)
185
- return;
186
-
187
- // Replace to reference to app.services.serviceName
188
- path.replaceWith(
189
- t.memberExpression(
190
- service.source === 'container'
191
- // container.Environment
192
- ? t.identifier( service.source )
193
- // application.services.Disks
194
- : t.memberExpression(
195
- t.identifier('this'),
196
- t.identifier('app'),
197
- ),
198
- path.node
199
- )
200
- );
201
-
202
- // Avoid circular loop
203
- serviceBinding.replaced = true;
204
- }
205
- }
206
- }
207
-
208
- return plugin;
209
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes