@dooboostore/simple-boot-http-server-ssr 1.0.11 → 1.0.12

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 (146) hide show
  1. package/README.MD +24 -209
  2. package/dist/cjs/bundle-entry.js +36 -0
  3. package/dist/cjs/bundle-entry.js.map +7 -0
  4. package/dist/cjs/codes/HttpHeaders.js.map +2 -2
  5. package/dist/cjs/filters/SSRFilter.js +4 -6
  6. package/dist/cjs/filters/SSRFilter.js.map +2 -2
  7. package/dist/cjs/filters/SSRWorker.js +1 -2
  8. package/dist/cjs/filters/SSRWorker.js.map +1 -1
  9. package/dist/cjs/index.js.map +2 -2
  10. package/dist/cjs/initializers/JsdomInitializer.js +1 -0
  11. package/dist/cjs/initializers/JsdomInitializer.js.map +2 -2
  12. package/dist/cjs/package.json +2 -0
  13. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js +17 -2
  14. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js.map +3 -3
  15. package/dist/esm/bundle-entry.js +9 -0
  16. package/dist/esm/bundle-entry.js.map +7 -0
  17. package/dist/esm/codes/HttpHeaders.js.map +2 -2
  18. package/dist/esm/filters/SSRFilter.js +4 -6
  19. package/dist/esm/filters/SSRFilter.js.map +2 -2
  20. package/dist/esm/filters/SSRWorker.js +1 -2
  21. package/dist/esm/filters/SSRWorker.js.map +1 -1
  22. package/dist/esm/index.js.map +2 -2
  23. package/dist/esm/initializers/JsdomInitializer.js +1 -0
  24. package/dist/esm/initializers/JsdomInitializer.js.map +2 -2
  25. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js +18 -3
  26. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js.map +3 -3
  27. package/dist/esm-bundle/dooboostore-simple-boot-http-server-ssr.esm.js +11372 -3
  28. package/dist/esm-bundle/dooboostore-simple-boot-http-server-ssr.esm.js.map +4 -4
  29. package/dist/{esm → types}/SimpleBootHttpSSRServer.d.ts +1 -1
  30. package/dist/types/bundle-entry.d.ts +9 -0
  31. package/dist/types/bundle-entry.d.ts.map +1 -0
  32. package/dist/types/codes/HttpHeaders.d.ts +45 -0
  33. package/dist/types/codes/HttpHeaders.d.ts.map +1 -0
  34. package/dist/{cjs → types}/filters/SSRFilter.d.ts.map +1 -1
  35. package/dist/types/index.d.ts +22 -0
  36. package/dist/{esm → types}/index.d.ts.map +1 -1
  37. package/dist/{cjs → types}/initializers/JsdomInitializer.d.ts.map +1 -1
  38. package/dist/{cjs → types}/proxy/SymbolIntentApiServiceProxy.d.ts.map +1 -1
  39. package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js +11364 -6
  40. package/dist/umd-bundle/dooboostore-simple-boot-http-server-ssr.umd.js.map +4 -4
  41. package/package.json +30 -18
  42. package/src/SimpleBootHttpSSRFactory.ts +11 -0
  43. package/src/SimpleBootHttpSSRServer.ts +21 -0
  44. package/src/bundle-entry.ts +8 -0
  45. package/src/codes/HttpHeaders.ts +17 -0
  46. package/src/codes/Mimes.ts +6 -0
  47. package/src/codes/index.ts +2 -0
  48. package/src/decorators/LoadAroundBefore.ts +28 -0
  49. package/src/decorators/SaveAroundAfter.ts +27 -0
  50. package/src/decorators/index.ts +2 -0
  51. package/src/filters/IntentSchemeFilter.ts +66 -0
  52. package/src/filters/SSRFilter.ts +339 -0
  53. package/src/filters/SSRWorker.ts +76 -0
  54. package/{dist/esm/filters/index.d.ts → src/filters/index.ts} +1 -2
  55. package/src/index.ts +9 -0
  56. package/src/initializers/JsdomInitializer.ts +85 -0
  57. package/src/initializers/index.ts +1 -0
  58. package/src/option/HttpSSRServerOption.ts +4 -0
  59. package/src/option/index.ts +1 -0
  60. package/src/proxy/IntentSchemeFrontProxy.ts +67 -0
  61. package/src/proxy/IntentSchemeServerProxy.ts +35 -0
  62. package/src/proxy/SymbolIntentApiServiceProxy.ts +131 -0
  63. package/src/proxy/SymbolIntentApiServiceProxyBase.ts +97 -0
  64. package/{dist/esm/proxy/index.d.ts → src/proxy/index.ts} +1 -2
  65. package/tsconfig.json +24 -0
  66. package/dist/cjs/SimpleBootHttpSSRServer.d.ts +0 -9
  67. package/dist/cjs/codes/HttpHeaders.d.ts +0 -45
  68. package/dist/cjs/codes/HttpHeaders.d.ts.map +0 -1
  69. package/dist/cjs/index.d.ts +0 -3
  70. package/dist/cjs/index.d.ts.map +0 -1
  71. package/dist/esm/SimpleBootHttpSSRFactory.d.ts +0 -8
  72. package/dist/esm/SimpleBootHttpSSRFactory.d.ts.map +0 -1
  73. package/dist/esm/SimpleBootHttpSSRServer.d.ts.map +0 -1
  74. package/dist/esm/codes/HttpHeaders.d.ts +0 -45
  75. package/dist/esm/codes/HttpHeaders.d.ts.map +0 -1
  76. package/dist/esm/codes/Mimes.d.ts +0 -31
  77. package/dist/esm/codes/Mimes.d.ts.map +0 -1
  78. package/dist/esm/codes/index.d.ts +0 -3
  79. package/dist/esm/codes/index.d.ts.map +0 -1
  80. package/dist/esm/decorators/LoadAroundBefore.d.ts +0 -2
  81. package/dist/esm/decorators/LoadAroundBefore.d.ts.map +0 -1
  82. package/dist/esm/decorators/SaveAroundAfter.d.ts +0 -3
  83. package/dist/esm/decorators/SaveAroundAfter.d.ts.map +0 -1
  84. package/dist/esm/decorators/index.d.ts +0 -3
  85. package/dist/esm/decorators/index.d.ts.map +0 -1
  86. package/dist/esm/filters/IntentSchemeFilter.d.ts +0 -20
  87. package/dist/esm/filters/IntentSchemeFilter.d.ts.map +0 -1
  88. package/dist/esm/filters/SSRFilter.d.ts +0 -59
  89. package/dist/esm/filters/SSRFilter.d.ts.map +0 -1
  90. package/dist/esm/filters/SSRWorker.d.ts +0 -16
  91. package/dist/esm/filters/SSRWorker.d.ts.map +0 -1
  92. package/dist/esm/filters/index.d.ts.map +0 -1
  93. package/dist/esm/index.d.ts +0 -3
  94. package/dist/esm/initializers/JsdomInitializer.d.ts +0 -11
  95. package/dist/esm/initializers/JsdomInitializer.d.ts.map +0 -1
  96. package/dist/esm/initializers/index.d.ts +0 -2
  97. package/dist/esm/initializers/index.d.ts.map +0 -1
  98. package/dist/esm/option/HttpSSRServerOption.d.ts +0 -4
  99. package/dist/esm/option/HttpSSRServerOption.d.ts.map +0 -1
  100. package/dist/esm/option/index.d.ts +0 -2
  101. package/dist/esm/option/index.d.ts.map +0 -1
  102. package/dist/esm/proxy/IntentSchemeFrontProxy.d.ts +0 -4
  103. package/dist/esm/proxy/IntentSchemeFrontProxy.d.ts.map +0 -1
  104. package/dist/esm/proxy/IntentSchemeServerProxy.d.ts +0 -4
  105. package/dist/esm/proxy/IntentSchemeServerProxy.d.ts.map +0 -1
  106. package/dist/esm/proxy/SymbolIntentApiServiceProxy.d.ts +0 -16
  107. package/dist/esm/proxy/SymbolIntentApiServiceProxy.d.ts.map +0 -1
  108. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.d.ts +0 -13
  109. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.d.ts.map +0 -1
  110. package/dist/esm/proxy/index.d.ts.map +0 -1
  111. /package/dist/{cjs → types}/SimpleBootHttpSSRFactory.d.ts +0 -0
  112. /package/dist/{cjs → types}/SimpleBootHttpSSRFactory.d.ts.map +0 -0
  113. /package/dist/{cjs → types}/SimpleBootHttpSSRServer.d.ts.map +0 -0
  114. /package/dist/{cjs → types}/codes/Mimes.d.ts +0 -0
  115. /package/dist/{cjs → types}/codes/Mimes.d.ts.map +0 -0
  116. /package/dist/{cjs → types}/codes/index.d.ts +0 -0
  117. /package/dist/{cjs → types}/codes/index.d.ts.map +0 -0
  118. /package/dist/{cjs → types}/decorators/LoadAroundBefore.d.ts +0 -0
  119. /package/dist/{cjs → types}/decorators/LoadAroundBefore.d.ts.map +0 -0
  120. /package/dist/{cjs → types}/decorators/SaveAroundAfter.d.ts +0 -0
  121. /package/dist/{cjs → types}/decorators/SaveAroundAfter.d.ts.map +0 -0
  122. /package/dist/{cjs → types}/decorators/index.d.ts +0 -0
  123. /package/dist/{cjs → types}/decorators/index.d.ts.map +0 -0
  124. /package/dist/{cjs → types}/filters/IntentSchemeFilter.d.ts +0 -0
  125. /package/dist/{cjs → types}/filters/IntentSchemeFilter.d.ts.map +0 -0
  126. /package/dist/{cjs → types}/filters/SSRFilter.d.ts +0 -0
  127. /package/dist/{cjs → types}/filters/SSRWorker.d.ts +0 -0
  128. /package/dist/{cjs → types}/filters/SSRWorker.d.ts.map +0 -0
  129. /package/dist/{cjs → types}/filters/index.d.ts +0 -0
  130. /package/dist/{cjs → types}/filters/index.d.ts.map +0 -0
  131. /package/dist/{cjs → types}/initializers/JsdomInitializer.d.ts +0 -0
  132. /package/dist/{cjs → types}/initializers/index.d.ts +0 -0
  133. /package/dist/{cjs → types}/initializers/index.d.ts.map +0 -0
  134. /package/dist/{cjs → types}/option/HttpSSRServerOption.d.ts +0 -0
  135. /package/dist/{cjs → types}/option/HttpSSRServerOption.d.ts.map +0 -0
  136. /package/dist/{cjs → types}/option/index.d.ts +0 -0
  137. /package/dist/{cjs → types}/option/index.d.ts.map +0 -0
  138. /package/dist/{cjs → types}/proxy/IntentSchemeFrontProxy.d.ts +0 -0
  139. /package/dist/{cjs → types}/proxy/IntentSchemeFrontProxy.d.ts.map +0 -0
  140. /package/dist/{cjs → types}/proxy/IntentSchemeServerProxy.d.ts +0 -0
  141. /package/dist/{cjs → types}/proxy/IntentSchemeServerProxy.d.ts.map +0 -0
  142. /package/dist/{cjs → types}/proxy/SymbolIntentApiServiceProxy.d.ts +0 -0
  143. /package/dist/{cjs → types}/proxy/SymbolIntentApiServiceProxyBase.d.ts +0 -0
  144. /package/dist/{cjs → types}/proxy/SymbolIntentApiServiceProxyBase.d.ts.map +0 -0
  145. /package/dist/{cjs → types}/proxy/index.d.ts +0 -0
  146. /package/dist/{cjs → types}/proxy/index.d.ts.map +0 -0
@@ -0,0 +1,76 @@
1
+ import { ConstructorType } from '@dooboostore/core/types';
2
+ import {FactoryAndParams} from './SSRFilter';
3
+ import {JsdomInitializer} from '../initializers/JsdomInitializer';
4
+ import JSDOM from 'jsdom';
5
+ import {RandomUtils} from '@dooboostore/core/random/RandomUtils';
6
+ import {SimpleBootFront} from '@dooboostore/simple-boot-front/SimpleBootFront';
7
+
8
+ export class SSRWorker {
9
+ public welcomUrl = 'http://localhost'
10
+ private simpleBootFront?: SimpleBootFront;
11
+
12
+ constructor(public factory: FactoryAndParams, public otherInstanceSim?: Map<ConstructorType<any>, any>) {
13
+
14
+ }
15
+
16
+ async run() {
17
+ this.simpleBootFront = await this.makeFront();
18
+ }
19
+
20
+ async makeJsdom() {
21
+ const jsdom = await new JsdomInitializer(this.factory.frontDistPath, this.factory.frontDistIndexFileName || 'index.html', {url: this.welcomUrl}).run();
22
+ return jsdom;
23
+ }
24
+
25
+ async makeFront(jsdom?: JSDOM.JSDOM) {
26
+ if (!jsdom) {
27
+ jsdom = await this.makeJsdom();
28
+ }
29
+ const name = RandomUtils.uuid();
30
+ // const jsdom = await this.makeJsdom();
31
+ const window = jsdom.window as unknown as Window & typeof globalThis;
32
+ (window as any).ssrUse = false;
33
+ const option = this.factory.factorySimFrontOption(window);
34
+ // option.name = name;
35
+ const simpleBootFront = await this.factory.factory.create(option, this.factory.using, this.factory.domExcludes);
36
+ simpleBootFront.run(this.otherInstanceSim);
37
+ (simpleBootFront as any).jsdom = jsdom;
38
+ return simpleBootFront;
39
+ }
40
+
41
+
42
+ async getHtml(url: string) {
43
+ if (this.simpleBootFront && (this.simpleBootFront.option.window as any).ssrUse) {
44
+
45
+ } else if (this.simpleBootFront) {
46
+ (this.simpleBootFront.option.window as any).ssrUse = true;
47
+ delete (this.simpleBootFront.option.window as any).server_side_data;
48
+
49
+ // run
50
+ await this.simpleBootFront.goRouting(url);
51
+ let html = this.simpleBootFront.option.window.document.documentElement.outerHTML;
52
+
53
+ const serverSideData = (this.simpleBootFront.option.window as any).server_side_data;
54
+ if (serverSideData) {
55
+ const data = Object.entries(serverSideData).map(([k, v]) => {
56
+ if (typeof v === 'string') {
57
+ return `window.server_side_data.${k} = ${v}`;
58
+ } else {
59
+ return `window.server_side_data.${k} = ${JSON.stringify(v)}`;
60
+ }
61
+ }).join(';');
62
+ if (data) {
63
+ html = html.replace('</head>', `<script> window.server_side_data={}; ${data}; </script></head>`);
64
+ }
65
+ }
66
+
67
+ this.makeFront().then(it => {
68
+ this.simpleBootFront = it;
69
+ });
70
+ return html;
71
+ } {
72
+
73
+ }
74
+
75
+ }
76
+ }
@@ -1,4 +1,3 @@
1
1
  export * from './IntentSchemeFilter';
2
2
  export * from './SSRFilter';
3
- export * from './SSRWorker';
4
- //# sourceMappingURL=index.d.ts.map
3
+ export * from './SSRWorker';
package/src/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ // export * from './codes';
2
+ // export * from './decorators';
3
+ // export * from './filters';
4
+ // export * from './initializers';
5
+ // export * from './option';
6
+ // export * from './proxy';
7
+ // export * from './SimpleBootHttpSSRFactory';
8
+ // export * from './SimpleBootHttpSSRServer';
9
+ export default {}
@@ -0,0 +1,85 @@
1
+ import * as JSDOM from 'jsdom';
2
+ import { ReconfigureSettings } from 'jsdom';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+
6
+ export class JsdomInitializer {
7
+ constructor(
8
+ private frontDistPath: string,
9
+ private frontDistIndexFileName: string,
10
+ private reconfigureSettings?: ReconfigureSettings
11
+ ) {}
12
+
13
+ public static loadFile(distPath: string, filePath: string): string {
14
+ return fs.readFileSync(path.join(distPath, filePath), 'utf8');
15
+ }
16
+
17
+ async run(): Promise<JSDOM.JSDOM> {
18
+ // const indexHTML = fs.readFileSync(path.join(this.frontDistPath, 'index.html'), 'utf8');
19
+ // const indexHTML = JsdomInitializer.loadFile(this.frontDistPath, this.frontDistIndexFileName);
20
+ const pathStr = path.join(this.frontDistPath, this.frontDistIndexFileName);
21
+
22
+ const jsdom = await JSDOM.JSDOM.fromFile(pathStr, {});
23
+ if (this.reconfigureSettings) {
24
+ jsdom.reconfigure(this.reconfigureSettings);
25
+ }
26
+ // devDependencies
27
+ // "@types/jsdom": "^21.1.2",
28
+ // "canvas": "^3.1.0",
29
+ // global setting
30
+ // @ts-ignore
31
+ global.document = jsdom.window.document;
32
+ // @ts-ignore
33
+ global.window = jsdom.window as unknown as Window & typeof globalThis;
34
+ // @ts-ignore
35
+ global.window.requestAnimationFrame = () => {};
36
+ global.window.scrollTo = () => {};
37
+ // const originalPushState = global.window.history.pushState;
38
+ // global.window.history.pushState = (data: any,title: any,path: string) => {
39
+ // console.log('----iida',path)
40
+ // path.replace()
41
+ //
42
+ // let s = `${UrlUtils.origin(global.window.location.href)}${path?`${path}`:''}`;
43
+ // console.log('----da',s)
44
+ // originalPushState.apply(global.window.history, [data, title, s]);
45
+ // }
46
+ // const originalReplaceState = global.window.history.replaceState;
47
+ // global.window.history.replaceState = (data: any,title: any,path: string) => {
48
+ // let s = `${UrlUtils.origin(global.window.location.href)}${path?`${path}`:''}`;
49
+ // originalReplaceState.apply(global.window.history, [data, title, s]);
50
+ // }
51
+ // const dummyResponse = {ok: false, json: () => Promise.resolve({})}; // as Response;
52
+ // global.fetch = (...data: any): Promise<any> => {
53
+ // console.log('dummy fetch')
54
+ // return Promise.resolve(dummyResponse)
55
+ // };
56
+ // @ts-ignore
57
+ global.history = jsdom.window.history;
58
+ global.Event = jsdom.window.Event;
59
+ // @ts-ignore
60
+ global.PopStateEvent = jsdom.window.Event;
61
+ global.IntersectionObserver = jsdom.window.IntersectionObserver;
62
+ // @ts-ignore
63
+ // global.Error = ErrorBase;
64
+ // @ts-ignore
65
+ // global.navigator = jsdom.window.navigator;
66
+ global.NodeFilter = jsdom.window.NodeFilter;
67
+ global.Node = jsdom.window.Node;
68
+ global.DocumentFragment = jsdom.window.DocumentFragment;
69
+ global.HTMLElement = jsdom.window.HTMLElement;
70
+ global.HTMLMetaElement = jsdom.window.HTMLMetaElement;
71
+ global.Element = jsdom.window.Element;
72
+ global.HTMLCanvasElement = jsdom.window.HTMLCanvasElement;
73
+ global.HTMLCanvasElement.prototype.getContext = () => {
74
+ return null;
75
+ };
76
+ global.CanvasRenderingContext2D = jsdom.window.CanvasRenderingContext2D;
77
+ global.CanvasPattern = jsdom.window.CanvasPattern;
78
+ global.CanvasGradient = jsdom.window.CanvasGradient;
79
+ global.Path2D = jsdom.window.Path2D;
80
+ global.ImageData = jsdom.window.ImageData;
81
+ return jsdom;
82
+ }
83
+ }
84
+ //
85
+ // export default new JsdomInitializer();
@@ -0,0 +1 @@
1
+ export * from './JsdomInitializer';
@@ -0,0 +1,4 @@
1
+ import { HttpServerOption } from '@dooboostore/simple-boot-http-server/option/HttpServerOption';
2
+
3
+ export class HttpSSRServerOption extends HttpServerOption {
4
+ }
@@ -0,0 +1 @@
1
+ export * from './HttpSSRServerOption';
@@ -0,0 +1,67 @@
1
+ import { getSim, Sim } from '@dooboostore/simple-boot/decorators/SimDecorator';
2
+ import { HttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';
3
+ import { HttpHeaders as SSRHttpHeaders } from '../codes/HttpHeaders';
4
+ import { Mimes as SSRMimes } from '../codes/Mimes';
5
+ import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';
6
+ import { ConvertUtils } from '@dooboostore/core/convert/ConvertUtils';
7
+
8
+ @Sim
9
+ export class IntentSchemeFrontProxy implements ProxyHandler<any> {
10
+ public get(target: any, prop: string): any {
11
+ const t = target[prop];
12
+ // TODO: 여기에 추가적인 프로퍼티 작성으 추가적으로 해야된다..
13
+ // if (typeof t === 'function') {
14
+ if (!['constructor', 'onProxyDomRender', 'toString'].includes(prop)) {
15
+ return (...args: any[]) => {
16
+ // const simstanceManager = target._SimpleBoot_simstanceManager;
17
+ const simOption = target._SimpleBoot_simOption;
18
+ const config = getSim(target);
19
+ // const scheme = getSim(target)?.scheme;
20
+ const firstScheme = ConvertUtils.flatArray(config?.scheme)[0];
21
+ const key = firstScheme + '_' + prop;
22
+ const type = ReflectUtils.getReturnType(target, prop);
23
+ const isHas = (key in (simOption.window.server_side_data ?? {}));
24
+ if (isHas) {
25
+ const data = simOption.window.server_side_data?.[key];
26
+ delete simOption.window.server_side_data?.[key];
27
+ let rdata;
28
+ if (type instanceof Promise) {
29
+ rdata = Promise.resolve(data);
30
+ } else {
31
+ rdata = data;
32
+ }
33
+ return rdata;
34
+ } else {
35
+ return fetch(`/${prop.toString()}`,
36
+ {
37
+ method: 'POST',
38
+ headers: {[HttpHeaders.ContentType]: SSRMimes.ApplicationJsonPostSimpleBootSsrIntentScheme, [SSRHttpHeaders.XSimpleBootSsrIntentScheme]: firstScheme ?? ''},
39
+ body: JSON.stringify(args[0])
40
+ }
41
+ ).then(async (res) => {
42
+ try {
43
+ const data = await res.json();
44
+ return data;
45
+ } catch(e) {
46
+ try {
47
+ return await res.text();
48
+ } catch(e) {
49
+ return undefined;
50
+ }
51
+ }
52
+ });
53
+ }
54
+ // return t.apply(target, args);
55
+ }
56
+ } else {
57
+ return t;
58
+ }
59
+ }
60
+
61
+
62
+ // apply(target: Function, thisArg: any, ...argumentsList: any[]): any {
63
+ // console.log('-IntentSchemeFrontProxyHandler----?????')
64
+ // return target(...argumentsList);
65
+ // }
66
+
67
+ }
@@ -0,0 +1,35 @@
1
+ import { getSim, Sim } from '@dooboostore/simple-boot/decorators/SimDecorator';
2
+
3
+ @Sim
4
+ export class IntentSchemeServerProxy implements ProxyHandler<any> {
5
+ public get(target: any, prop: string): any {
6
+ const t = target[prop];
7
+ if (typeof t === 'function') {
8
+ return (...args: any[]) => {
9
+
10
+ const simstanceManager = target._SimpleBoot_simstanceManager;
11
+ const simOption = target._SimpleBoot_simOption;
12
+ const config = getSim(target);
13
+ const data = t.apply(target, args);
14
+ if (simstanceManager && simOption && config?.scheme && simOption.window) {
15
+ if (!simOption.window.server_side_data) {
16
+ simOption.window.server_side_data = {};
17
+ }
18
+ const key = config.scheme + '_' + prop;
19
+ if (data instanceof Promise) {
20
+ data.then((it) => {
21
+ simOption.window.server_side_data[key] = JSON.stringify(it);
22
+ return it;
23
+ });
24
+ } else {
25
+ simOption.window.server_side_data[key] = JSON.stringify(data);
26
+ }
27
+ }
28
+ return data;
29
+ }
30
+ } else {
31
+ return t;
32
+ }
33
+ }
34
+
35
+ }
@@ -0,0 +1,131 @@
1
+ import { getSim, Sim } from '@dooboostore/simple-boot/decorators/SimDecorator';
2
+ import { makeIntentHeaderBySymbol } from '../codes/HttpHeaders';
3
+ import { ConvertUtils } from '@dooboostore/core/convert/ConvertUtils';
4
+ import { ApiService } from '@dooboostore/simple-boot/fetch/ApiService';
5
+
6
+
7
+ export type Config<T = any> = { method?:'get' | 'post' | 'petch' | 'delete' | 'head', multipartFormData?: boolean, bypassTransform?: boolean; transformText?: boolean, headers?: HeadersInit, body?: T };
8
+ const _ = ApiService;
9
+ @Sim
10
+ export class SymbolIntentApiServiceProxy<T extends object> implements ProxyHandler<T> {
11
+
12
+
13
+ constructor(private apiService: ApiService) {
14
+ console.log('-------apiService', apiService);
15
+ }
16
+
17
+ get(target: T, prop: string | symbol, receiver: any): any {
18
+ const simConfig = getSim(target)
19
+ const apiService = this.apiService;
20
+ const value = Reflect.get(target, prop, receiver);
21
+ if (typeof value === 'function' && simConfig?.symbol) {
22
+ return function (...args: any[]) {
23
+ const f = value as Function;
24
+ const p = (userConfig: Config) => {
25
+
26
+ const headers = {...(userConfig?.headers ?? {}), ...makeIntentHeaderBySymbol(simConfig.symbol as Symbol)};
27
+ const method = userConfig?.method ?? 'post';
28
+ if(method === 'post' && userConfig?.multipartFormData) {
29
+ return apiService.post({
30
+ target: `/${String(prop)}`,
31
+ config: {
32
+ bypassTransform: userConfig?.bypassTransform,
33
+ transformText: userConfig?.transformText,
34
+ fetch: {
35
+ credentials: 'include',
36
+ headers: headers,
37
+ body: ConvertUtils.toFormData(userConfig?.body)
38
+ }
39
+ }
40
+ });
41
+ } else if (method === 'post') {
42
+ return apiService.postJson({
43
+ target: `/${String(prop)}`,
44
+ config: {
45
+ bypassTransform: userConfig?.bypassTransform,
46
+ transformText: userConfig?.transformText,
47
+ fetch: {
48
+ credentials: 'include',
49
+ headers: headers,
50
+ body: userConfig?.body
51
+ }
52
+ }
53
+ });
54
+ }else if (method === 'petch') {
55
+ return apiService.patchJson({
56
+ target: `/${String(prop)}`,
57
+ config: {
58
+ bypassTransform: userConfig?.bypassTransform,
59
+ transformText: userConfig?.transformText,
60
+ fetch: {
61
+ credentials: 'include',
62
+ headers: headers,
63
+ body: userConfig?.body
64
+ }
65
+ }
66
+ });
67
+ } else {
68
+ return apiService[method]({
69
+ // return apiService.head({
70
+ target: {url: `/${String(prop)}`, searchParams: userConfig?.body},
71
+ config: {
72
+ bypassTransform: userConfig?.bypassTransform,
73
+ transformText: userConfig?.transformText,
74
+ fetch: {
75
+ credentials: 'include',
76
+ headers: headers,
77
+ }
78
+ }
79
+ });
80
+ }
81
+
82
+
83
+
84
+
85
+ // if (userConfig?.multipartFormData) {
86
+ // return apiService.post({
87
+ // target: `/${String(prop)}`,
88
+ // config: {
89
+ // bypassTransform: userConfig?.bypassTransform,
90
+ // transformText: userConfig?.transformText,
91
+ // fetch: {
92
+ // credentials: 'include',
93
+ // headers: headers,
94
+ // body: ConvertUtils.toFormData(userConfig?.body)
95
+ // }
96
+ // }
97
+ // });
98
+ // } else {
99
+ // return apiService.postJson({
100
+ // target: `/${String(prop)}`,
101
+ // config: {
102
+ // bypassTransform: userConfig?.bypassTransform,
103
+ // transformText: userConfig?.transformText,
104
+ // fetch: {
105
+ // credentials: 'include',
106
+ // headers: headers,
107
+ // body: userConfig?.body
108
+ // }
109
+ // }
110
+ // });
111
+ // }
112
+
113
+ };
114
+ args.push(p);
115
+ return Reflect.apply(f, target, args);
116
+ // return f.apply(target, args);
117
+ }
118
+ }
119
+ return Reflect.get(target, prop, receiver);
120
+ }
121
+
122
+ apply(target: T, thisArg: any, argArray: any[]): any {
123
+ console.log('SymbolIntentApiServiceProxy apply')
124
+ // @ts-ignore
125
+ return Reflect.apply(target, thisArg, argArray);
126
+ }
127
+
128
+
129
+
130
+
131
+ }
@@ -0,0 +1,97 @@
1
+ import { getSim, Sim } from '@dooboostore/simple-boot/decorators/SimDecorator';
2
+ import { makeIntentHeaderBySymbol } from '../codes/HttpHeaders';
3
+ import { ConvertUtils } from '@dooboostore/core/convert/ConvertUtils';
4
+ import { ApiService } from '@dooboostore/simple-boot/fetch/ApiService';
5
+
6
+
7
+ export type SymbolIntentApiServiceProxyBaseConfig<T = any> = { method?:'get' | 'post' | 'petch' | 'delete' | 'head', multipartFormData?: boolean, bypassTransform?: boolean; transformText?: boolean, headers?: HeadersInit, body?: T };
8
+
9
+ export class SymbolIntentApiServiceProxyBase<T extends object = any> {
10
+ // 생성자는 프록시될 대상 객체(target)와 의존성을 주입받습니다.
11
+ constructor(
12
+ apiService: ApiService,
13
+ ) {
14
+ // ProxyHandler 객체를 정의합니다.
15
+ const handler: ProxyHandler<T> = {
16
+ get(target: T, prop: string | symbol, receiver: any): any {
17
+ const simConfig = getSim(target)
18
+ const value = Reflect.get(target, prop, receiver);
19
+ if (typeof value === 'function' && simConfig?.symbol) {
20
+ return function (...args: any[]) {
21
+ const f = value as Function;
22
+ const p = (userConfig: SymbolIntentApiServiceProxyBaseConfig) => {
23
+ const headers = {...(userConfig?.headers ?? {}), ...makeIntentHeaderBySymbol(simConfig.symbol as Symbol)};
24
+ const method = userConfig?.method ?? 'post';
25
+ if(method === 'post' && userConfig?.multipartFormData) {
26
+ return apiService.post({
27
+ target: `/${String(prop)}`,
28
+ config: {
29
+ bypassTransform: userConfig?.bypassTransform,
30
+ transformText: userConfig?.transformText,
31
+ fetch: {
32
+ credentials: 'include',
33
+ headers: headers,
34
+ body: ConvertUtils.toFormData(userConfig?.body)
35
+ }
36
+ }
37
+ });
38
+ } else if (method === 'post') {
39
+ return apiService.postJson({
40
+ target: `/${String(prop)}`,
41
+ config: {
42
+ bypassTransform: userConfig?.bypassTransform,
43
+ transformText: userConfig?.transformText,
44
+ fetch: {
45
+ credentials: 'include',
46
+ headers: headers,
47
+ body: userConfig?.body
48
+ }
49
+ }
50
+ });
51
+ }else if (method === 'petch') {
52
+ return apiService.patchJson({
53
+ target: `/${String(prop)}`,
54
+ config: {
55
+ bypassTransform: userConfig?.bypassTransform,
56
+ transformText: userConfig?.transformText,
57
+ fetch: {
58
+ credentials: 'include',
59
+ headers: headers,
60
+ body: userConfig?.body
61
+ }
62
+ }
63
+ });
64
+ } else {
65
+ return apiService[method]({
66
+ target: {url: `/${String(prop)}`, searchParams: userConfig?.body},
67
+ config: {
68
+ bypassTransform: userConfig?.bypassTransform,
69
+ transformText: userConfig?.transformText,
70
+ fetch: {
71
+ credentials: 'include',
72
+ headers: headers,
73
+ }
74
+ }
75
+ });
76
+ }
77
+ };
78
+ args.push(p);
79
+ return Reflect.apply(f, target, args);
80
+ }
81
+ }
82
+ return Reflect.get(target, prop, receiver);
83
+ },
84
+
85
+ apply(target: T, thisArg: any, argArray: any[]): any {
86
+ console.log('SymbolIntentApiServiceProxyBase apply (from handler)');
87
+ // @ts-ignore
88
+ return Reflect.apply(target, thisArg, argArray);
89
+ }
90
+ };
91
+
92
+ // 생성자에서 Proxy 객체를 반환합니다.
93
+
94
+ // @ts-ignore
95
+ return new Proxy(this, handler);
96
+ }
97
+ }
@@ -1,5 +1,4 @@
1
1
  export * from './IntentSchemeFrontProxy';
2
2
  export * from './IntentSchemeServerProxy';
3
3
  export * from './SymbolIntentApiServiceProxy';
4
- export * from './SymbolIntentApiServiceProxyBase';
5
- //# sourceMappingURL=index.d.ts.map
4
+ export * from './SymbolIntentApiServiceProxyBase';
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "src",
4
+ "declarationDir": "dist/types",
5
+ "sourceMap": true,
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "stripInternal": true,
9
+ "target": "es2020",
10
+ "lib": ["dom", "dom.iterable", "esnext"],
11
+ "experimentalDecorators": true,
12
+ "emitDecoratorMetadata": true,
13
+ "esModuleInterop": true,
14
+ "skipLibCheck": true,
15
+ "moduleResolution": "node",
16
+ "baseUrl": ".",
17
+ "paths": {
18
+ // "@dooboostore/core/*": ["../../core/src/*"],
19
+ // "@dooboostore/core": ["../../core/src/index.ts"]
20
+ }
21
+ },
22
+ "include": ["src/**/*.ts"],
23
+ "exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts", "example", "test"]
24
+ }
@@ -1,9 +0,0 @@
1
- import { SimpleBootHttpServer } from '@dooboostore/simple-boot-http-server/SimpleBootHttpServer';
2
- import { HttpSSRServerOption } from './option/HttpSSRServerOption';
3
- import { ConstructorType } from '@dooboostore/core/types';
4
- export declare class SimpleBootHttpSSRServer extends SimpleBootHttpServer {
5
- constructor(option?: HttpSSRServerOption);
6
- run(otherInstanceSim?: Map<ConstructorType<any>, any>): import("@dooboostore/simple-boot/simstance/SimstanceManager").SimstanceManager;
7
- stop(): void;
8
- }
9
- //# sourceMappingURL=SimpleBootHttpSSRServer.d.ts.map
@@ -1,45 +0,0 @@
1
- import { HttpHeaders as AHttpHeaders } from '@dooboostore/simple-boot-http-server/codes/HttpHeaders';
2
- export declare const HttpHeaders: {
3
- XSimpleBootSsrIntentScheme: string;
4
- ContentLength: AHttpHeaders.ContentLength;
5
- ContentType: AHttpHeaders.ContentType;
6
- ContentEncoding: AHttpHeaders.ContentEncoding;
7
- Accept: AHttpHeaders.Accept;
8
- Authorization: AHttpHeaders.Authorization;
9
- CacheControl: AHttpHeaders.CacheControl;
10
- Connection: AHttpHeaders.Connection;
11
- Date: AHttpHeaders.Date;
12
- Host: AHttpHeaders.Host;
13
- Pragma: AHttpHeaders.Pragma;
14
- Trailer: AHttpHeaders.Trailer;
15
- TransferEncoding: AHttpHeaders.TransferEncoding;
16
- Upgrade: AHttpHeaders.Upgrade;
17
- Via: AHttpHeaders.Via;
18
- Warning: AHttpHeaders.Warning;
19
- AcceptCharset: AHttpHeaders.AcceptCharset;
20
- AcceptEncoding: AHttpHeaders.AcceptEncoding;
21
- AcceptLanguage: AHttpHeaders.AcceptLanguage;
22
- AccessControlAllowOrigin: AHttpHeaders.AccessControlAllowOrigin;
23
- AccessControlAllowMethods: AHttpHeaders.AccessControlAllowMethods;
24
- AccessControlAllowHeaders: AHttpHeaders.AccessControlAllowHeaders;
25
- AccessControlExposeHeaders: AHttpHeaders.AccessControlExposeHeaders;
26
- Expect: AHttpHeaders.Expect;
27
- From: AHttpHeaders.From;
28
- MaxForwards: AHttpHeaders.MaxForwards;
29
- Referer: AHttpHeaders.Referer;
30
- UserAgent: AHttpHeaders.UserAgent;
31
- Cookie: AHttpHeaders.Cookie;
32
- SetCookie: AHttpHeaders.SetCookie;
33
- Cookie2: AHttpHeaders.Cookie2;
34
- SetCookie2: AHttpHeaders.SetCookie2;
35
- Location: AHttpHeaders.Location;
36
- IfModifiedSince: AHttpHeaders.IfModifiedSince;
37
- IfUnmodifiedSince: AHttpHeaders.IfUnmodifiedSince;
38
- IfMatch: AHttpHeaders.IfMatch;
39
- IfNoneMatch: AHttpHeaders.IfNoneMatch;
40
- IfRange: AHttpHeaders.IfRange;
41
- Allow: AHttpHeaders.Allow;
42
- Server: AHttpHeaders.Server;
43
- };
44
- export declare const makeIntentHeaderBySymbol: (symbol: Symbol) => HeadersInit;
45
- //# sourceMappingURL=HttpHeaders.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HttpHeaders.d.ts","sourceRoot":"","sources":["../../../src/codes/HttpHeaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,wDAAwD,CAAC;AAGrG,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGvB,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,QAAQ,MAAM,KAAG,WAKzD,CAAC"}
@@ -1,3 +0,0 @@
1
- declare const _default: {};
2
- export default _default;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAQA,wBAEC"}
@@ -1,8 +0,0 @@
1
- import { SimpleBootFront } from '@dooboostore/simple-boot-front/SimpleBootFront';
2
- import { ConstructorType } from '@dooboostore/core/types';
3
- import { SimFrontOption } from '@dooboostore/simple-boot-front/option/SimFrontOption';
4
- export declare abstract class SimpleBootHttpSSRFactory {
5
- abstract factory(simFrontOption: SimFrontOption, using: (ConstructorType<any> | Function)[], domExcludes: ConstructorType<any>[]): Promise<SimpleBootFront>;
6
- create(simFrontOption: SimFrontOption, using?: (ConstructorType<any> | Function)[], domExcludes?: ConstructorType<any>[]): Promise<SimpleBootFront>;
7
- }
8
- //# sourceMappingURL=SimpleBootHttpSSRFactory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SimpleBootHttpSSRFactory.d.ts","sourceRoot":"","sources":["../../src/SimpleBootHttpSSRFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAC;AACtF,8BAAsB,wBAAwB;aAC1B,OAAO,CAAC,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAErJ,MAAM,CAAC,cAAc,EAAE,cAAc,EAAE,KAAK,GAAE,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,EAAO,EAAE,WAAW,GAAE,eAAe,CAAC,GAAG,CAAC,EAAO,GAAG,OAAO,CAAC,eAAe,CAAC;CAI3K"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SimpleBootHttpSSRServer.d.ts","sourceRoot":"","sources":["../../src/SimpleBootHttpSSRServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2DAA2D,CAAC;AAEjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,qBAAa,uBAAwB,SAAQ,oBAAoB;gBACnD,MAAM,CAAC,EAAE,mBAAmB;IAIxC,GAAG,CAAC,gBAAgB,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;IAOrD,IAAI;CAGL"}