catalyst-core-internal 0.0.1-beta.2 → 0.0.1-beta.21

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 (110) hide show
  1. package/.eslintignore +9 -0
  2. package/.eslintrc +91 -0
  3. package/.husky/commit-msg +1 -0
  4. package/.husky/pre-commit +1 -0
  5. package/README.md +45 -43
  6. package/babel.config.json +2 -5
  7. package/bin/catalyst.js +33 -35
  8. package/caching.js +1 -16
  9. package/changelog.md +12 -0
  10. package/commitlint.config.js +11 -0
  11. package/config.json +1 -1
  12. package/index.js +1 -16
  13. package/license +10 -0
  14. package/logger.js +3 -89
  15. package/package.json +89 -83
  16. package/router/ClientRouter.js +2 -18
  17. package/router/ServerRouter.js +1 -19
  18. package/router.js +1 -16
  19. package/scripts/build.js +9 -28
  20. package/scripts/checkVersion.js +1 -5
  21. package/scripts/devBuild.js +10 -0
  22. package/scripts/devServe.js +5 -0
  23. package/scripts/loadEnvironmentVariables.js +4 -23
  24. package/scripts/loadScriptsBeforeServerStarts.js +5 -47
  25. package/scripts/resiterAliases.js +29 -0
  26. package/scripts/scriptUtils.js +2 -0
  27. package/scripts/serve.js +4 -29
  28. package/scripts/start.js +5 -25
  29. package/scripts/validator.js +1 -130
  30. package/server/expressServer.js +8 -49
  31. package/server/renderer/document/Body.js +6 -28
  32. package/server/renderer/document/Head.js +5 -39
  33. package/server/renderer/document/index.js +1 -27
  34. package/server/renderer/extract.js +6 -72
  35. package/server/renderer/handler.js +14 -241
  36. package/server/renderer/index.js +1 -12
  37. package/server/renderer/render.js +8 -60
  38. package/server/startServer.js +6 -65
  39. package/server/utils/userAgentUtil.js +3 -49
  40. package/server/utils/validator.js +1 -130
  41. package/webpack/babel-plugins/remove-client.plugin.js +3 -29
  42. package/webpack/babel-plugins/remove-ssr.plugin.js +3 -19
  43. package/webpack/babel.config.client.js +1 -24
  44. package/webpack/babel.config.ssr.js +1 -24
  45. package/webpack/base.babel.js +8 -167
  46. package/webpack/development.client.babel.js +4 -82
  47. package/webpack/production.client.babel.js +4 -78
  48. package/webpack/production.ssr.babel.js +4 -61
  49. package/webpack/scssParams.js +5 -31
  50. package/packages/create-framework-app/templates/redux-js/node_modules/@babel/core/lib/config/caching.js +0 -261
  51. package/packages/create-framework-app/templates/redux-js/node_modules/@remix-run/router/dist/router.js +0 -4327
  52. package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/router.js +0 -15
  53. package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/src/router.js +0 -1
  54. package/packages/create-framework-app/templates/redux-js/node_modules/http-proxy-middleware/dist/router.js +0 -46
  55. package/router/index.js +0 -32
  56. package/scripts/prepare.js +0 -19
  57. package/scripts/registerAliases.js +0 -30
  58. package/server/mainIndex.js +0 -65
  59. package/server/mainServer.js +0 -70
  60. package/server/renderer/userAgentUtil.js +0 -55
  61. package/types/caching.d.ts +0 -1
  62. package/types/config/config.d.ts +0 -19
  63. package/types/index.d.ts +0 -1
  64. package/types/logger/index.d.ts +0 -14
  65. package/types/reducer/index.d.ts +0 -22
  66. package/types/reducer/loadableConfigReducer.d.ts +0 -9
  67. package/types/router/ClientRouter.d.ts +0 -5
  68. package/types/router/ServerRouter.d.ts +0 -7
  69. package/types/router/index.d.ts +0 -8
  70. package/types/router.d.ts +0 -1
  71. package/types/scripts/build.d.ts +0 -1
  72. package/types/scripts/loadEnvironmentVariables.d.ts +0 -5
  73. package/types/scripts/loadScriptsBeforeServerStarts.d.ts +0 -1
  74. package/types/scripts/prepare.d.ts +0 -1
  75. package/types/scripts/registerAliases.d.ts +0 -1
  76. package/types/scripts/serve.d.ts +0 -1
  77. package/types/scripts/start.d.ts +0 -1
  78. package/types/scripts/validator.d.ts +0 -9
  79. package/types/scripts/verifyConfig.d.ts +0 -1
  80. package/types/server/mainIndex.d.ts +0 -1
  81. package/types/server/mainServer.d.ts +0 -2
  82. package/types/server/renderer/document/Body.d.ts +0 -11
  83. package/types/server/renderer/document/Head.d.ts +0 -11
  84. package/types/server/renderer/document/index.d.ts +0 -2
  85. package/types/server/renderer/extract.d.ts +0 -18
  86. package/types/server/renderer/handler.d.ts +0 -6
  87. package/types/server/renderer/index.d.ts +0 -2
  88. package/types/server/renderer/render.d.ts +0 -38
  89. package/types/server/renderer/userAgentUtil.d.ts +0 -1
  90. package/types/store/index.d.ts +0 -11
  91. package/types/store/index.dev.d.ts +0 -8
  92. package/types/store/index.prod.d.ts +0 -8
  93. package/types/webpack/babel-plugins/remove-client.plugin.d.ts +0 -10
  94. package/types/webpack/babel-plugins/remove-ssr.plugin.d.ts +0 -10
  95. package/types/webpack/babel.config.client.d.ts +0 -21
  96. package/types/webpack/babel.config.d.ts +0 -16
  97. package/types/webpack/babel.config.ssr.d.ts +0 -21
  98. package/types/webpack/base.babel.d.ts +0 -184
  99. package/types/webpack/development.client.babel.d.ts +0 -1
  100. package/types/webpack/plugins/mime-types.d.ts +0 -78
  101. package/types/webpack/plugins/route-manifest-plugin.d.ts +0 -1
  102. package/types/webpack/plugins/upload-assets-plugin.d.ts +0 -1
  103. package/types/webpack/production.client.babel.d.ts +0 -174
  104. package/types/webpack/production.ssr.babel.d.ts +0 -2
  105. package/types/webpack/scssParams.d.ts +0 -2
  106. package/webpack/babel.config.js +0 -20
  107. package/webpack/plugins/mime-types.js +0 -82
  108. package/webpack/plugins/route-manifest-copy.js +0 -122
  109. package/webpack/plugins/route-manifest-plugin.js +0 -122
  110. package/webpack/plugins/upload-assets-plugin.js +0 -181
@@ -1,261 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.assertSimpleType = assertSimpleType;
7
- exports.makeStrongCache = makeStrongCache;
8
- exports.makeStrongCacheSync = makeStrongCacheSync;
9
- exports.makeWeakCache = makeWeakCache;
10
- exports.makeWeakCacheSync = makeWeakCacheSync;
11
- function _gensync() {
12
- const data = require("gensync");
13
- _gensync = function () {
14
- return data;
15
- };
16
- return data;
17
- }
18
- var _async = require("../gensync-utils/async.js");
19
- var _util = require("./util.js");
20
- const synchronize = gen => {
21
- return _gensync()(gen).sync;
22
- };
23
- function* genTrue() {
24
- return true;
25
- }
26
- function makeWeakCache(handler) {
27
- return makeCachedFunction(WeakMap, handler);
28
- }
29
- function makeWeakCacheSync(handler) {
30
- return synchronize(makeWeakCache(handler));
31
- }
32
- function makeStrongCache(handler) {
33
- return makeCachedFunction(Map, handler);
34
- }
35
- function makeStrongCacheSync(handler) {
36
- return synchronize(makeStrongCache(handler));
37
- }
38
- function makeCachedFunction(CallCache, handler) {
39
- const callCacheSync = new CallCache();
40
- const callCacheAsync = new CallCache();
41
- const futureCache = new CallCache();
42
- return function* cachedFunction(arg, data) {
43
- const asyncContext = yield* (0, _async.isAsync)();
44
- const callCache = asyncContext ? callCacheAsync : callCacheSync;
45
- const cached = yield* getCachedValueOrWait(asyncContext, callCache, futureCache, arg, data);
46
- if (cached.valid) return cached.value;
47
- const cache = new CacheConfigurator(data);
48
- const handlerResult = handler(arg, cache);
49
- let finishLock;
50
- let value;
51
- if ((0, _util.isIterableIterator)(handlerResult)) {
52
- value = yield* (0, _async.onFirstPause)(handlerResult, () => {
53
- finishLock = setupAsyncLocks(cache, futureCache, arg);
54
- });
55
- } else {
56
- value = handlerResult;
57
- }
58
- updateFunctionCache(callCache, cache, arg, value);
59
- if (finishLock) {
60
- futureCache.delete(arg);
61
- finishLock.release(value);
62
- }
63
- return value;
64
- };
65
- }
66
- function* getCachedValue(cache, arg, data) {
67
- const cachedValue = cache.get(arg);
68
- if (cachedValue) {
69
- for (const {
70
- value,
71
- valid
72
- } of cachedValue) {
73
- if (yield* valid(data)) return {
74
- valid: true,
75
- value
76
- };
77
- }
78
- }
79
- return {
80
- valid: false,
81
- value: null
82
- };
83
- }
84
- function* getCachedValueOrWait(asyncContext, callCache, futureCache, arg, data) {
85
- const cached = yield* getCachedValue(callCache, arg, data);
86
- if (cached.valid) {
87
- return cached;
88
- }
89
- if (asyncContext) {
90
- const cached = yield* getCachedValue(futureCache, arg, data);
91
- if (cached.valid) {
92
- const value = yield* (0, _async.waitFor)(cached.value.promise);
93
- return {
94
- valid: true,
95
- value
96
- };
97
- }
98
- }
99
- return {
100
- valid: false,
101
- value: null
102
- };
103
- }
104
- function setupAsyncLocks(config, futureCache, arg) {
105
- const finishLock = new Lock();
106
- updateFunctionCache(futureCache, config, arg, finishLock);
107
- return finishLock;
108
- }
109
- function updateFunctionCache(cache, config, arg, value) {
110
- if (!config.configured()) config.forever();
111
- let cachedValue = cache.get(arg);
112
- config.deactivate();
113
- switch (config.mode()) {
114
- case "forever":
115
- cachedValue = [{
116
- value,
117
- valid: genTrue
118
- }];
119
- cache.set(arg, cachedValue);
120
- break;
121
- case "invalidate":
122
- cachedValue = [{
123
- value,
124
- valid: config.validator()
125
- }];
126
- cache.set(arg, cachedValue);
127
- break;
128
- case "valid":
129
- if (cachedValue) {
130
- cachedValue.push({
131
- value,
132
- valid: config.validator()
133
- });
134
- } else {
135
- cachedValue = [{
136
- value,
137
- valid: config.validator()
138
- }];
139
- cache.set(arg, cachedValue);
140
- }
141
- }
142
- }
143
- class CacheConfigurator {
144
- constructor(data) {
145
- this._active = true;
146
- this._never = false;
147
- this._forever = false;
148
- this._invalidate = false;
149
- this._configured = false;
150
- this._pairs = [];
151
- this._data = void 0;
152
- this._data = data;
153
- }
154
- simple() {
155
- return makeSimpleConfigurator(this);
156
- }
157
- mode() {
158
- if (this._never) return "never";
159
- if (this._forever) return "forever";
160
- if (this._invalidate) return "invalidate";
161
- return "valid";
162
- }
163
- forever() {
164
- if (!this._active) {
165
- throw new Error("Cannot change caching after evaluation has completed.");
166
- }
167
- if (this._never) {
168
- throw new Error("Caching has already been configured with .never()");
169
- }
170
- this._forever = true;
171
- this._configured = true;
172
- }
173
- never() {
174
- if (!this._active) {
175
- throw new Error("Cannot change caching after evaluation has completed.");
176
- }
177
- if (this._forever) {
178
- throw new Error("Caching has already been configured with .forever()");
179
- }
180
- this._never = true;
181
- this._configured = true;
182
- }
183
- using(handler) {
184
- if (!this._active) {
185
- throw new Error("Cannot change caching after evaluation has completed.");
186
- }
187
- if (this._never || this._forever) {
188
- throw new Error("Caching has already been configured with .never or .forever()");
189
- }
190
- this._configured = true;
191
- const key = handler(this._data);
192
- const fn = (0, _async.maybeAsync)(handler, `You appear to be using an async cache handler, but Babel has been called synchronously`);
193
- if ((0, _async.isThenable)(key)) {
194
- return key.then(key => {
195
- this._pairs.push([key, fn]);
196
- return key;
197
- });
198
- }
199
- this._pairs.push([key, fn]);
200
- return key;
201
- }
202
- invalidate(handler) {
203
- this._invalidate = true;
204
- return this.using(handler);
205
- }
206
- validator() {
207
- const pairs = this._pairs;
208
- return function* (data) {
209
- for (const [key, fn] of pairs) {
210
- if (key !== (yield* fn(data))) return false;
211
- }
212
- return true;
213
- };
214
- }
215
- deactivate() {
216
- this._active = false;
217
- }
218
- configured() {
219
- return this._configured;
220
- }
221
- }
222
- function makeSimpleConfigurator(cache) {
223
- function cacheFn(val) {
224
- if (typeof val === "boolean") {
225
- if (val) cache.forever();else cache.never();
226
- return;
227
- }
228
- return cache.using(() => assertSimpleType(val()));
229
- }
230
- cacheFn.forever = () => cache.forever();
231
- cacheFn.never = () => cache.never();
232
- cacheFn.using = cb => cache.using(() => assertSimpleType(cb()));
233
- cacheFn.invalidate = cb => cache.invalidate(() => assertSimpleType(cb()));
234
- return cacheFn;
235
- }
236
- function assertSimpleType(value) {
237
- if ((0, _async.isThenable)(value)) {
238
- throw new Error(`You appear to be using an async cache handler, ` + `which your current version of Babel does not support. ` + `We may add support for this in the future, ` + `but if you're on the most recent version of @babel/core and still ` + `seeing this error, then you'll need to synchronously handle your caching logic.`);
239
- }
240
- if (value != null && typeof value !== "string" && typeof value !== "boolean" && typeof value !== "number") {
241
- throw new Error("Cache keys must be either string, boolean, number, null, or undefined.");
242
- }
243
- return value;
244
- }
245
- class Lock {
246
- constructor() {
247
- this.released = false;
248
- this.promise = void 0;
249
- this._resolve = void 0;
250
- this.promise = new Promise(resolve => {
251
- this._resolve = resolve;
252
- });
253
- }
254
- release(value) {
255
- this.released = true;
256
- this._resolve(value);
257
- }
258
- }
259
- 0 && 0;
260
-
261
- //# sourceMappingURL=caching.js.map