@omnia/tooling-vue 7.5.75-dev → 8.0.0-dev
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.
- package/internal-do-not-import-from-here/babel/preset-jsx.d.ts +2 -8
- package/internal-do-not-import-from-here/babel/preset-jsx.js +7 -105
- package/internal-do-not-import-from-here/config/omnia.vendor.manifest.json +1 -1
- package/internal-do-not-import-from-here/config/tooling.output.json +1 -0
- package/internal-do-not-import-from-here/config/wctypings.d.ts +2038 -0
- package/internal-do-not-import-from-here/index.d.ts +3 -1
- package/internal-do-not-import-from-here/index.js +6 -2
- package/internal-do-not-import-from-here/shared.d.ts +32 -100
- package/internal-do-not-import-from-here/shared.js +97 -208
- package/internal-do-not-import-from-here/swc/extract-doc-plugin/package.json +14 -0
- package/internal-do-not-import-from-here/tasks/ComponentDocRegistrations.d.ts +1 -0
- package/internal-do-not-import-from-here/tasks/ComponentDocRegistrations.js +9 -0
- package/internal-do-not-import-from-here/tasks/bundle.d.ts +3 -4
- package/internal-do-not-import-from-here/tasks/bundle.js +304 -353
- package/internal-do-not-import-from-here/tasks/doc.d.ts +3 -1
- package/internal-do-not-import-from-here/tasks/doc.js +282 -395
- package/internal-do-not-import-from-here/tasks/tsc.js +1 -0
- package/internal-do-not-import-from-here/tasks/vendor.js +163 -40
- package/internal-do-not-import-from-here/variables.d.ts +1 -1
- package/internal-do-not-import-from-here/variables.js +2 -2
- package/internal-do-not-import-from-here/vite/hmr/graph.js +6 -2
- package/internal-do-not-import-from-here/vite/hmr/manifest.js +6 -7
- package/internal-do-not-import-from-here/vite/hmr/runtime.js +8 -6
- package/internal-do-not-import-from-here/vite/hmr/transformers/importPath.js +10 -6
- package/internal-do-not-import-from-here/vite/hmr/transformers/internal/dynamicBundle.js +14 -3
- package/internal-do-not-import-from-here/vite/hmr/transformers/internal/omniaRuntime.js +8 -8
- package/internal-do-not-import-from-here/vite/hmr/transformers/vendorImportPath.d.ts +4 -0
- package/internal-do-not-import-from-here/vite/hmr/transformers/vendorImportPath.js +2 -1
- package/internal-do-not-import-from-here/vite/hmr/utils/manifest.js +3 -3
- package/internal-do-not-import-from-here/vite/hmr/utils/path.js +12 -8
- package/internal-do-not-import-from-here/vite/hmr/utils/webpack.js +2 -2
- package/internal-do-not-import-from-here/vite/hmr/vueJsx.d.ts +4 -3
- package/internal-do-not-import-from-here/vite/hmr/vueJsx.js +160 -54
- package/internal-do-not-import-from-here/vite/index.js +4 -0
- package/internal-do-not-import-from-here/vite/middlewares/HmrMiddleware.js +22 -18
- package/internal-do-not-import-from-here/vite/middlewares/OmniaMiddleware.js +55 -17
- package/internal-do-not-import-from-here/vite/middlewares/StaticFileMiddleware.js +32 -11
- package/internal-do-not-import-from-here/vite/middlewares/WebpackMiddleware.js +1 -1
- package/internal-do-not-import-from-here/vite/plugins/OmniaPlugin.js +44 -26
- package/internal-do-not-import-from-here/wctypings.ts +0 -0
- package/internal-do-not-import-from-here/webpack-loaders/doc-loader.js +11 -0
- package/internal-do-not-import-from-here/webpack-loaders/ingore-vuetify-locale.js +1 -1
- package/internal-do-not-import-from-here/webpack-loaders/ts-loader.d.ts +11 -4
- package/internal-do-not-import-from-here/webpack-loaders/ts-loader.js +12 -12
- package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.d.ts +25 -4
- package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.js +33 -32
- package/internal-do-not-import-from-here/webpack-loaders/wc-loader.d.ts +1 -0
- package/internal-do-not-import-from-here/webpack-loaders/wc-loader.js +11 -0
- package/package.json +14 -11
- package/internal-do-not-import-from-here/1cacb55c-202b-4cd7-819d-11bad92fa9cb.wcdefinitions.json +0 -1
- package/internal-do-not-import-from-here/1cacb55c-202b-4cd7-819d-11bad92fa9cb.wctypings.d.ts +0 -11
- package/internal-do-not-import-from-here/bb000000-0000-bbbb-0000-0000000000bb.wcdefinitions.json +0 -1
- package/internal-do-not-import-from-here/bb000000-0000-bbbb-0000-0000000000bb.wctypings.d.ts +0 -322
- package/internal-do-not-import-from-here/bb000000-0000-bbbb-0000-0000000000bb.wctypings.js +0 -2
- package/internal-do-not-import-from-here/cc000000-0000-cccc-0000-0000000000cc.wcdefinitions.json +0 -1
- package/internal-do-not-import-from-here/config/tsconfig.es2015.json +0 -21
- package/internal-do-not-import-from-here/webpack-loaders/esbuild-custom-loader.js +0 -13
- package/internal-do-not-import-from-here/webpack-loaders/jsx-loader.d.ts +0 -8
- package/internal-do-not-import-from-here/webpack-loaders/jsx-loader.js +0 -61
- package/internal-do-not-import-from-here/webpack-loaders/vue-tsx-hot-loader.d.ts +0 -1
- package/internal-do-not-import-from-here/webpack-loaders/vue-tsx-hot-loader.js +0 -44
- package/internal-do-not-import-from-here/webpack-loaders/wcmanifest-loader.d.ts +0 -1
- package/internal-do-not-import-from-here/webpack-loaders/wcmanifest-loader.js +0 -10
- /package/internal-do-not-import-from-here/{1cacb55c-202b-4cd7-819d-11bad92fa9cb.wctypings.js → config/wctypings.js} +0 -0
- /package/internal-do-not-import-from-here/webpack-loaders/{esbuild-custom-loader.d.ts → doc-loader.d.ts} +0 -0
|
@@ -1,67 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.transformVueJsx = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
6
|
const core_1 = require("@babel/core");
|
|
7
|
-
const fx_models_1 = require("@omnia/fx-models");
|
|
8
7
|
const $ = tslib_1.__importStar(require("../../variables"));
|
|
9
|
-
|
|
10
|
-
const
|
|
8
|
+
function transformVueJsx(code, id) {
|
|
9
|
+
const result = (0, core_1.transformSync)(code, {
|
|
11
10
|
ast: true,
|
|
12
11
|
presets: [
|
|
13
12
|
[
|
|
14
13
|
// '@vue/babel-preset-jsx',
|
|
15
14
|
$.isExtensionEnv ?
|
|
16
15
|
'./node_modules/@omnia/tooling-vue/internal-do-not-import-from-here/babel/preset-jsx.js'
|
|
17
|
-
: './client/tooling/vue/babel/preset-jsx.ts'
|
|
18
|
-
{
|
|
19
|
-
vModel: true,
|
|
20
|
-
compositionAPI: true,
|
|
21
|
-
}
|
|
16
|
+
: './client/tooling/vue/babel/preset-jsx.ts'
|
|
22
17
|
]
|
|
23
18
|
]
|
|
24
19
|
});
|
|
25
|
-
|
|
26
|
-
return babelTransformResult.code;
|
|
27
|
-
}
|
|
28
|
-
exports.transformVueJsx = transformVueJsx;
|
|
29
|
-
// Customized from plugin-vue-jsx https://github.com/vitejs/vite/blob/main/packages/plugin-vue-jsx/index.js
|
|
30
|
-
function injectHotReloadScript(babelFile, code, id) {
|
|
31
|
-
const [hotComponents, hasDefault] = getHotComponents(babelFile, code, id);
|
|
32
|
-
if (hotComponents.length) {
|
|
33
|
-
if (hasDefault) {
|
|
34
|
-
babelFile.code = babelFile.code.replace(/export default defineVueComponent/g, `const __default__ = defineVueComponent`);
|
|
35
|
-
babelFile.code = babelFile.code.replace(/export default defineVueWebComponent/g, `const __default__ = defineVueWebComponent`);
|
|
36
|
-
}
|
|
37
|
-
if (!/\?vue&type=script/.test(id)) {
|
|
38
|
-
let code = babelFile.code;
|
|
39
|
-
let callbackCode = ``;
|
|
40
|
-
code = '\n' +
|
|
41
|
-
`const __VUE_HOT_RELOAD_API__ = omniaWebpackJsonp['bb000000-0000-bbbb-0000-0000000000bb']['${fx_models_1.OmniaResourceManifests.HMR}']('f8ee4fc2-3876-4997-80d7-5264eaee44bb');` + '\n' + code;
|
|
42
|
-
for (const { local, exported, id } of hotComponents) {
|
|
43
|
-
code +=
|
|
44
|
-
`\n\n/**\n * Vue Hot Reload\n */\n${local}.__hmrId = "${id}";` +
|
|
45
|
-
`\n__VUE_HOT_RELOAD_API__.createRecord("${id}", ${local});`;
|
|
46
|
-
callbackCode = callbackCode + '\n\n' +
|
|
47
|
-
` __VUE_HOT_RELOAD_API__.reload("${id}", __${exported});`;
|
|
48
|
-
}
|
|
49
|
-
code += `\nimport.meta.hot.accept(({${hotComponents
|
|
50
|
-
.map((c) => `${c.exported}: __${c.exported}`)
|
|
51
|
-
.join(',')}}) => {${callbackCode}\n});`;
|
|
52
|
-
babelFile.code = code;
|
|
53
|
-
}
|
|
54
|
-
if (hasDefault) {
|
|
55
|
-
babelFile.code += `\n\nexport default __default__;`;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.injectHotReloadScript = injectHotReloadScript;
|
|
60
|
-
function getHotComponents(babelFile, code, id) {
|
|
61
|
-
let hasDefault = false;
|
|
20
|
+
// check for hmr injection
|
|
62
21
|
const declaredComponents = [];
|
|
63
22
|
const hotComponents = [];
|
|
64
|
-
|
|
23
|
+
let hasDefault = false;
|
|
24
|
+
for (const node of result.ast.program.body) {
|
|
65
25
|
if (node.type === 'VariableDeclaration') {
|
|
66
26
|
const names = parseComponentDecls(node, code);
|
|
67
27
|
if (names.length) {
|
|
@@ -70,11 +30,22 @@ function getHotComponents(babelFile, code, id) {
|
|
|
70
30
|
}
|
|
71
31
|
if (node.type === 'ExportNamedDeclaration') {
|
|
72
32
|
if (node.declaration &&
|
|
73
|
-
node.declaration.type === '
|
|
33
|
+
(node.declaration.type === 'ClassDeclaration')) {
|
|
34
|
+
if (node.declaration.superClass?.type === 'Identifier'
|
|
35
|
+
&& node.declaration.superClass?.name === 'VueComponentBase') {
|
|
36
|
+
hotComponents.push({
|
|
37
|
+
local: node.declaration.id.name,
|
|
38
|
+
exported: node.declaration.id.name,
|
|
39
|
+
id: getHash(id + node.declaration.id.name)
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if (node.declaration &&
|
|
44
|
+
(node.declaration.type === 'VariableDeclaration')) {
|
|
74
45
|
hotComponents.push(...parseComponentDecls(node.declaration, code).map(({ name }) => ({
|
|
75
46
|
local: name,
|
|
76
47
|
exported: name,
|
|
77
|
-
id: (
|
|
48
|
+
id: getHash(id + name),
|
|
78
49
|
})));
|
|
79
50
|
}
|
|
80
51
|
else if (node.specifiers.length) {
|
|
@@ -86,7 +57,7 @@ function getHotComponents(babelFile, code, id) {
|
|
|
86
57
|
hotComponents.push({
|
|
87
58
|
local: spec.local.name,
|
|
88
59
|
exported: spec.exported.name,
|
|
89
|
-
id: (
|
|
60
|
+
id: getHash(id + spec.exported.name),
|
|
90
61
|
});
|
|
91
62
|
}
|
|
92
63
|
}
|
|
@@ -101,7 +72,7 @@ function getHotComponents(babelFile, code, id) {
|
|
|
101
72
|
hotComponents.push({
|
|
102
73
|
local: node.declaration.name,
|
|
103
74
|
exported: 'default',
|
|
104
|
-
id: (
|
|
75
|
+
id: getHash(id + 'default'),
|
|
105
76
|
});
|
|
106
77
|
}
|
|
107
78
|
}
|
|
@@ -110,13 +81,145 @@ function getHotComponents(babelFile, code, id) {
|
|
|
110
81
|
hotComponents.push({
|
|
111
82
|
local: '__default__',
|
|
112
83
|
exported: 'default',
|
|
113
|
-
id: (
|
|
84
|
+
id: getHash(id + 'default'),
|
|
114
85
|
});
|
|
115
86
|
}
|
|
116
87
|
}
|
|
117
88
|
}
|
|
118
|
-
|
|
89
|
+
if (hotComponents.length) {
|
|
90
|
+
if (hasDefault) {
|
|
91
|
+
result.code =
|
|
92
|
+
result.code.replace(/export default defineVueWebComponent/g, `const __default__ = defineVueWebComponent`).replace(/export default defineVueComponent/g, `const __default__ = defineVueComponent`) + `\nexport default __default__`;
|
|
93
|
+
}
|
|
94
|
+
if (!/\?vue&type=script/.test(id)) {
|
|
95
|
+
let code = result.code;
|
|
96
|
+
let callbackCode = ``;
|
|
97
|
+
for (const { local, exported, id } of hotComponents) {
|
|
98
|
+
code +=
|
|
99
|
+
`\n${local}.__hmrId = "${id}"` +
|
|
100
|
+
`\n__VUE_HMR_RUNTIME__.createRecord("${id}", ${local})`;
|
|
101
|
+
callbackCode += `\n__VUE_HMR_RUNTIME__.reload("${id}", __${exported})`;
|
|
102
|
+
}
|
|
103
|
+
code += `\nimport.meta.hot.accept(({${hotComponents
|
|
104
|
+
.map((c) => `${c.exported}: __${c.exported}`)
|
|
105
|
+
.join(',')}}) => {${callbackCode}\n})`;
|
|
106
|
+
result.code = code;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (!result.code)
|
|
110
|
+
return;
|
|
111
|
+
return {
|
|
112
|
+
code: result.code,
|
|
113
|
+
map: result.map,
|
|
114
|
+
};
|
|
119
115
|
}
|
|
116
|
+
exports.transformVueJsx = transformVueJsx;
|
|
117
|
+
// Customized from plugin-vue-jsx https://github.com/vitejs/vite/blob/main/packages/plugin-vue-jsx/index.js
|
|
118
|
+
// export function injectHotReloadScript(babelFile: BabelFileResult, code: string, id: string) {
|
|
119
|
+
// const [hotComponents, hasDefault] = getHotComponents(babelFile, code, id);
|
|
120
|
+
// if (hotComponents.length) {
|
|
121
|
+
// if (hasDefault) {
|
|
122
|
+
// babelFile.code = babelFile.code.replace(
|
|
123
|
+
// /export default defineVueComponent/g,
|
|
124
|
+
// `const __default__ = defineVueComponent`
|
|
125
|
+
// );
|
|
126
|
+
// babelFile.code = babelFile.code.replace(
|
|
127
|
+
// /export default defineVueWebComponent/g,
|
|
128
|
+
// `const __default__ = defineVueWebComponent`
|
|
129
|
+
// );
|
|
130
|
+
// }
|
|
131
|
+
// if (!/\?vue&type=script/.test(id)) {
|
|
132
|
+
// let code = babelFile.code;
|
|
133
|
+
// let callbackCode = ``;
|
|
134
|
+
// code = '\n' +
|
|
135
|
+
// `const __VUE_HOT_RELOAD_API__ = omniaWebpackJsonp['bb000000-0000-bbbb-0000-0000000000bb']['${OmniaResourceManifests.HMR}']('f8ee4fc2-3876-4997-80d7-5264eaee44bb');` + '\n' + code;
|
|
136
|
+
// for (const { local, exported, id } of hotComponents) {
|
|
137
|
+
// code +=
|
|
138
|
+
// `\n\n/**\n * Vue Hot Reload\n */\n${local}.__hmrId = "${id}";` +
|
|
139
|
+
// `\n__VUE_HOT_RELOAD_API__.createRecord("${id}", ${local});`;
|
|
140
|
+
// callbackCode = callbackCode + '\n\n' +
|
|
141
|
+
// ` __VUE_HOT_RELOAD_API__.reload("${id}", __${exported});`;
|
|
142
|
+
// }
|
|
143
|
+
// code += `\nimport.meta.hot.accept(({${hotComponents
|
|
144
|
+
// .map((c) => `${c.exported}: __${c.exported}`)
|
|
145
|
+
// .join(',')}}) => {${callbackCode}\n});`;
|
|
146
|
+
// babelFile.code = code;
|
|
147
|
+
// }
|
|
148
|
+
// if (hasDefault) {
|
|
149
|
+
// babelFile.code += `\n\nexport default __default__;`;
|
|
150
|
+
// }
|
|
151
|
+
// }
|
|
152
|
+
// }
|
|
153
|
+
// function getHotComponents(babelFile: BabelFileResult, code: string, id: string): [Array<HotComponent>, boolean] {
|
|
154
|
+
// let hasDefault = false;
|
|
155
|
+
// const declaredComponents: Array<{ name: string }> = [];
|
|
156
|
+
// const hotComponents: Array<HotComponent> = [];
|
|
157
|
+
// for (const node of babelFile.ast.program.body) {
|
|
158
|
+
// if (node.type === 'VariableDeclaration') {
|
|
159
|
+
// const names = parseComponentDecls(node, code)
|
|
160
|
+
// if (names.length) {
|
|
161
|
+
// declaredComponents.push(...names)
|
|
162
|
+
// }
|
|
163
|
+
// }
|
|
164
|
+
// if (node.type === 'ExportNamedDeclaration') {
|
|
165
|
+
// if (
|
|
166
|
+
// node.declaration &&
|
|
167
|
+
// node.declaration.type === 'VariableDeclaration'
|
|
168
|
+
// ) {
|
|
169
|
+
// hotComponents.push(
|
|
170
|
+
// ...parseComponentDecls(node.declaration, code).map(
|
|
171
|
+
// ({ name }) => ({
|
|
172
|
+
// local: name,
|
|
173
|
+
// exported: name,
|
|
174
|
+
// id: hash(id + name)
|
|
175
|
+
// })
|
|
176
|
+
// )
|
|
177
|
+
// )
|
|
178
|
+
// } else if (node.specifiers.length) {
|
|
179
|
+
// for (const spec of node.specifiers) {
|
|
180
|
+
// if (
|
|
181
|
+
// spec.type === 'ExportSpecifier' &&
|
|
182
|
+
// spec.exported.type === 'Identifier'
|
|
183
|
+
// ) {
|
|
184
|
+
// const matched = declaredComponents.find(
|
|
185
|
+
// ({ name }) => name === spec.local.name
|
|
186
|
+
// )
|
|
187
|
+
// if (matched) {
|
|
188
|
+
// hotComponents.push({
|
|
189
|
+
// local: spec.local.name,
|
|
190
|
+
// exported: spec.exported.name,
|
|
191
|
+
// id: hash(id + spec.exported.name)
|
|
192
|
+
// })
|
|
193
|
+
// }
|
|
194
|
+
// }
|
|
195
|
+
// }
|
|
196
|
+
// }
|
|
197
|
+
// }
|
|
198
|
+
// if (node.type === 'ExportDefaultDeclaration') {
|
|
199
|
+
// if (node.declaration.type === 'Identifier') {
|
|
200
|
+
// const _name = node.declaration.name
|
|
201
|
+
// const matched = declaredComponents.find(
|
|
202
|
+
// ({ name }) => name === _name
|
|
203
|
+
// )
|
|
204
|
+
// if (matched) {
|
|
205
|
+
// hotComponents.push({
|
|
206
|
+
// local: node.declaration.name,
|
|
207
|
+
// exported: 'default',
|
|
208
|
+
// id: hash(id + 'default')
|
|
209
|
+
// })
|
|
210
|
+
// }
|
|
211
|
+
// } else if (isDefineComponentCall(node.declaration)) {
|
|
212
|
+
// hasDefault = true
|
|
213
|
+
// hotComponents.push({
|
|
214
|
+
// local: '__default__',
|
|
215
|
+
// exported: 'default',
|
|
216
|
+
// id: hash(id + 'default')
|
|
217
|
+
// })
|
|
218
|
+
// }
|
|
219
|
+
// }
|
|
220
|
+
// }
|
|
221
|
+
// return [hotComponents, hasDefault];
|
|
222
|
+
// }
|
|
120
223
|
function parseComponentDecls(node, source) {
|
|
121
224
|
const names = [];
|
|
122
225
|
for (const decl of node.declarations) {
|
|
@@ -141,3 +244,6 @@ function isClassComponentCall(node) {
|
|
|
141
244
|
node.superClass.type === 'Identifier' &&
|
|
142
245
|
(node.superClass.name === 'VueComponentBase' || node.superClass.name === 'Vue'));
|
|
143
246
|
}
|
|
247
|
+
function getHash(text) {
|
|
248
|
+
return (0, node_crypto_1.createHash)('sha256').update(text).digest('hex').substring(0, 8);
|
|
249
|
+
}
|
|
@@ -10,6 +10,7 @@ const del_1 = tslib_1.__importDefault(require("del"));
|
|
|
10
10
|
const tooling_composers_1 = require("@omnia/tooling-composers");
|
|
11
11
|
const tooling_1 = require("@omnia/tooling");
|
|
12
12
|
const plugins_1 = require("./plugins");
|
|
13
|
+
const vite_plugin_inspect_1 = tslib_1.__importDefault(require("vite-plugin-inspect"));
|
|
13
14
|
async function createViteServer() {
|
|
14
15
|
const hosting = (0, tooling_composers_1.getHosting)();
|
|
15
16
|
let plugins = [
|
|
@@ -17,6 +18,9 @@ async function createViteServer() {
|
|
|
17
18
|
hosting: hosting
|
|
18
19
|
})
|
|
19
20
|
];
|
|
21
|
+
if (hosting.enableProfiling) {
|
|
22
|
+
plugins.push((0, vite_plugin_inspect_1.default)());
|
|
23
|
+
}
|
|
20
24
|
let https = hosting.https || await getCert();
|
|
21
25
|
let serverConfig = {
|
|
22
26
|
configFile: false,
|
|
@@ -65,7 +65,6 @@ function registerHmrMiddleware(server) {
|
|
|
65
65
|
console.error(message);
|
|
66
66
|
}
|
|
67
67
|
else if (resourceId == fx_models_1.OmniaResourceManifests.Vendor.toString() ||
|
|
68
|
-
resourceId == fx_models_1.OmniaResourceManifests.HMR.toString() ||
|
|
69
68
|
resourceId == fx_models_1.OmniaResourceManifests.FxWorkers.toString()) {
|
|
70
69
|
const serviceId = $.tooling.composer.getServiceId();
|
|
71
70
|
const bundleDirPath = utils_1.envUtils.getBundleOutputDirPath();
|
|
@@ -108,14 +107,26 @@ function registerHmrMiddleware(server) {
|
|
|
108
107
|
});
|
|
109
108
|
server.middlewares.use(utils_1.pathUtils.HMR_DYNAMIC_BUNDLE_REQUEST, async (req, res, next) => {
|
|
110
109
|
res.setHeader('Content-Type', 'application/x-javascript');
|
|
110
|
+
const ext = req.url.split(".").pop();
|
|
111
111
|
const { resourceId, fromWorker } = utils_1.pathUtils.parseHmrDynamicBundlePath(req.url);
|
|
112
112
|
const bundleDirPath = utils_1.envUtils.getBundleOutputDirPath();
|
|
113
|
-
const bundleFileName = `dynamicbundle_${resourceId}
|
|
113
|
+
const bundleFileName = `dynamicbundle_${resourceId}.${ext}`;
|
|
114
114
|
const bundlePath = path_1.default.join(bundleDirPath, bundleFileName);
|
|
115
|
-
let
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
let content = await fs_1.default.promises.readFile(bundlePath, 'utf8');
|
|
116
|
+
if (ext === "js") {
|
|
117
|
+
// webpack bundled as commonjs so we need to make this as es module
|
|
118
|
+
content = content + '\n\n' + `//Empty export to make this as es module\nexport {}`;
|
|
119
|
+
//res.end(content);
|
|
120
|
+
}
|
|
121
|
+
else if (ext === "css") {
|
|
122
|
+
content = `import { updateStyle as __vite__updateStyle} from "/@vite/client";
|
|
123
|
+
const __vite__css = ${JSON.stringify(content)}
|
|
124
|
+
__vite__updateStyle("${bundleFileName}", __vite__css)`;
|
|
125
|
+
// req.url = `/omnia/dist/hmr/bundles/${bundleFileName}`;
|
|
126
|
+
// console.log("Hmr middleware", req.url)
|
|
127
|
+
// next();
|
|
128
|
+
}
|
|
129
|
+
res.end(content);
|
|
119
130
|
});
|
|
120
131
|
}
|
|
121
132
|
exports.registerHmrMiddleware = registerHmrMiddleware;
|
|
@@ -281,12 +292,7 @@ const manifestResolvePromise = new Promise(function (resolve) {
|
|
|
281
292
|
resolveManifest = resolve;
|
|
282
293
|
});
|
|
283
294
|
|
|
284
|
-
omniaLoader['${serviceId}']['${resourceId}'] = function (
|
|
285
|
-
if (preBundle && !preBundleLoader) {
|
|
286
|
-
preBundleLoader = preBundle;
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
|
|
295
|
+
omniaLoader['${serviceId}']['${resourceId}'] = function () {
|
|
290
296
|
if (triggered) {
|
|
291
297
|
return manifestResolvePromise;
|
|
292
298
|
}
|
|
@@ -314,8 +320,8 @@ omniaLoader['${serviceId}']['${resourceId}'] = function (preBundle) {
|
|
|
314
320
|
|
|
315
321
|
// pre-bundle exports
|
|
316
322
|
let preBundleWebpackRequire;
|
|
317
|
-
if (
|
|
318
|
-
|
|
323
|
+
if (typeof hmrPreBundle === "function") {
|
|
324
|
+
hmrPreBundle();
|
|
319
325
|
}
|
|
320
326
|
|
|
321
327
|
function require(moduleId) {
|
|
@@ -333,7 +339,7 @@ omniaLoader['${serviceId}']['${resourceId}'] = function (preBundle) {
|
|
|
333
339
|
}
|
|
334
340
|
|
|
335
341
|
${fromWorker ?
|
|
336
|
-
`const { href } = new URL('${host}${utils_1.pathUtils.HMR_ESM_REQUEST}/${resourceId}
|
|
342
|
+
`const { href } = new URL('${host}${utils_1.pathUtils.HMR_ESM_REQUEST}/${resourceId}?${utils_1.pathUtils.WORKER_IDENTIFIER}', location.href);
|
|
337
343
|
__shimport__.load(href).then(function () {
|
|
338
344
|
if (omniaWebpackJsonp['${serviceId}']['${resourceId}']) {
|
|
339
345
|
preBundleWebpackRequire = omniaWebpackJsonp['${serviceId}']['${resourceId}'];
|
|
@@ -342,7 +348,7 @@ omniaLoader['${serviceId}']['${resourceId}'] = function (preBundle) {
|
|
|
342
348
|
omniaWebpackJsonp['${serviceId}']['${resourceId}'] = require;
|
|
343
349
|
resolveManifest();
|
|
344
350
|
});` :
|
|
345
|
-
`import('${
|
|
351
|
+
`import('${utils_1.pathUtils.HMR_ESM_REQUEST}/${resourceId}').then(function () {
|
|
346
352
|
if (omniaWebpackJsonp['${serviceId}']['${resourceId}']) {
|
|
347
353
|
preBundleWebpackRequire = omniaWebpackJsonp['${serviceId}']['${resourceId}'];
|
|
348
354
|
}
|
|
@@ -353,9 +359,7 @@ omniaLoader['${serviceId}']['${resourceId}'] = function (preBundle) {
|
|
|
353
359
|
|
|
354
360
|
return manifestResolvePromise;
|
|
355
361
|
}
|
|
356
|
-
|
|
357
362
|
${preBundleContent}
|
|
358
|
-
|
|
359
363
|
${forGroupManifest ? 'return manifestResolvePromise;' : `${$.composers.LoadableManifestRegistry.isDefineWithNoDependency(resourceId) ? `omniaLoader['${serviceId}']['${resourceId}']();` : ''}`}
|
|
360
364
|
`;
|
|
361
365
|
return template.trim();
|
|
@@ -3,11 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.registerOmniaMiddleware = exports.ManifestChangedMessage = exports.resolvableManifest = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
|
|
6
|
+
const url_1 = tslib_1.__importDefault(require("url"));
|
|
6
7
|
const tooling_1 = require("@omnia/tooling");
|
|
7
8
|
const tooling_2 = require("@omnia/tooling");
|
|
8
9
|
const $ = tslib_1.__importStar(require("../../variables"));
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
const fx_models_1 = require("@omnia/fx-models");
|
|
11
|
+
const fsExtra = tslib_1.__importStar(require("fs-extra"));
|
|
12
|
+
let _middlewares = null;
|
|
13
|
+
let _server = null;
|
|
11
14
|
class ImplementManifestChangedMessage {
|
|
12
15
|
constructor() {
|
|
13
16
|
this._subcribers = [];
|
|
@@ -22,7 +25,8 @@ class ImplementManifestChangedMessage {
|
|
|
22
25
|
exports.resolvableManifest = null;
|
|
23
26
|
exports.ManifestChangedMessage = new ImplementManifestChangedMessage();
|
|
24
27
|
function registerOmniaMiddleware(server, hmr) {
|
|
25
|
-
|
|
28
|
+
_server = server;
|
|
29
|
+
_middlewares = server.middlewares;
|
|
26
30
|
server.middlewares.use('/omnia', function (req, res, next) {
|
|
27
31
|
ensureLoadManifest();
|
|
28
32
|
exports.resolvableManifest.promise.then(() => {
|
|
@@ -33,12 +37,9 @@ function registerOmniaMiddleware(server, hmr) {
|
|
|
33
37
|
res.setHeader('Content-Type', 'application/json');
|
|
34
38
|
res.end(JSON.stringify({ id: $.composers.ServiceManifestRegistry.getServiceInfo().id, hmr: hmr }));
|
|
35
39
|
});
|
|
36
|
-
server.middlewares.use('/omnia/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//if (server.config.server.hmr) {
|
|
40
|
-
// manifestJson.groupedResouresAndComponents = [];
|
|
41
|
-
//}
|
|
40
|
+
server.middlewares.use('/omnia/manifest.json', function (req, res, next) {
|
|
41
|
+
const target = url_1.default.parse(req.url, true).query.target;
|
|
42
|
+
let manifestJson = JSON.parse(JSON.stringify($.tooling.composer.getManifestJsonByTarget(target)));
|
|
42
43
|
res.setHeader('Cache-Control', 'no-cache');
|
|
43
44
|
res.setHeader('Content-Type', 'application/json');
|
|
44
45
|
res.end(JSON.stringify({
|
|
@@ -46,6 +47,13 @@ function registerOmniaMiddleware(server, hmr) {
|
|
|
46
47
|
manifest: manifestJson
|
|
47
48
|
}));
|
|
48
49
|
});
|
|
50
|
+
server.middlewares.use('/omnia/localization', function (req, res, next) {
|
|
51
|
+
const target = url_1.default.parse(req.url, true).query.target;
|
|
52
|
+
let localizeObject = $.composers.getLocalizations();
|
|
53
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
54
|
+
res.setHeader('Content-Type', 'application/json');
|
|
55
|
+
res.end(JSON.stringify(localizeObject[target] || ""));
|
|
56
|
+
});
|
|
49
57
|
let watchManifests = chokidar_1.default.watch(["**/*.manifest.ts", "omnia.service.ts"], {
|
|
50
58
|
ignored: [/[\/\\]\./, '**/node_modules/**'],
|
|
51
59
|
persistent: true
|
|
@@ -53,12 +61,24 @@ function registerOmniaMiddleware(server, hmr) {
|
|
|
53
61
|
watchManifests.on('ready', function () {
|
|
54
62
|
watchManifests
|
|
55
63
|
.on('add', path => {
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
if (isLocalizeManifestFile(path)) {
|
|
65
|
+
$.tooling.utils.log(`Found localize manifest file added -> ${path}`);
|
|
66
|
+
rebuildLocalization(path);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
$.tooling.utils.log(`Found manifest added -> ${path}`);
|
|
70
|
+
rebuildManifests();
|
|
71
|
+
}
|
|
58
72
|
})
|
|
59
73
|
.on('change', path => {
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
if (isLocalizeManifestFile(path)) {
|
|
75
|
+
$.tooling.utils.log(`Found localize manifest file changed -> ${path}`);
|
|
76
|
+
rebuildLocalization(path);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
$.tooling.utils.log(`Found manifest changed -> ${path}`);
|
|
80
|
+
rebuildManifests();
|
|
81
|
+
}
|
|
62
82
|
})
|
|
63
83
|
.on('unlink', path => {
|
|
64
84
|
$.tooling.utils.log(`Found manifest removed -> ${path}`);
|
|
@@ -70,6 +90,24 @@ function registerOmniaMiddleware(server, hmr) {
|
|
|
70
90
|
// setTimeout(ensureLoadManifest, 100);
|
|
71
91
|
}
|
|
72
92
|
exports.registerOmniaMiddleware = registerOmniaMiddleware;
|
|
93
|
+
function isLocalizeManifestFile(filePath) {
|
|
94
|
+
const content = fsExtra.readFileSync(filePath, 'utf8');
|
|
95
|
+
return content.indexOf(".registerLocalization") > -1;
|
|
96
|
+
}
|
|
97
|
+
function rebuildLocalization(filePath) {
|
|
98
|
+
try {
|
|
99
|
+
$.tooling.composer.processManifests([filePath]);
|
|
100
|
+
let localizeObject = $.composers.getLocalizations();
|
|
101
|
+
const payLoad = {
|
|
102
|
+
type: fx_models_1.LocalServingMessageType.LocalizeChanged,
|
|
103
|
+
data: localizeObject
|
|
104
|
+
};
|
|
105
|
+
_server.ws.send(payLoad);
|
|
106
|
+
}
|
|
107
|
+
catch (ex) {
|
|
108
|
+
// ignore ex because that already log error inside $.tooling.composer.processManifests
|
|
109
|
+
}
|
|
110
|
+
}
|
|
73
111
|
function rebuildManifests() {
|
|
74
112
|
tooling_1.utils.timeWatch("omniamiddleware_watchmanifest", () => {
|
|
75
113
|
if (exports.resolvableManifest) {
|
|
@@ -91,14 +129,14 @@ function rebuildManifests() {
|
|
|
91
129
|
tooling_1.utils.log(e, tooling_2.LogTypes.Error);
|
|
92
130
|
}
|
|
93
131
|
}
|
|
94
|
-
},
|
|
132
|
+
}, 100);
|
|
95
133
|
}
|
|
96
134
|
function ensureLoadManifest() {
|
|
97
|
-
if (
|
|
135
|
+
if (_middlewares && !exports.resolvableManifest) {
|
|
98
136
|
exports.resolvableManifest = new tooling_2.ResolvablePromise();
|
|
99
|
-
|
|
137
|
+
// ManifestChangedMessage.publish();
|
|
100
138
|
var tasks = tooling_1.core.getRegisteredServeTasks().filter(function (task) { return task.stage === tooling_1.core.TaskStage.AfterCreateServer; }).sort(sortTask) || [];
|
|
101
|
-
executeTasks(tasks,
|
|
139
|
+
executeTasks(tasks, _middlewares, () => {
|
|
102
140
|
exports.resolvableManifest.resolve();
|
|
103
141
|
}, err => {
|
|
104
142
|
exports.resolvableManifest.resolve();
|
|
@@ -6,16 +6,36 @@ const tooling_1 = require("@omnia/tooling");
|
|
|
6
6
|
const $ = tslib_1.__importStar(require("../../variables"));
|
|
7
7
|
const fx_models_1 = require("@omnia/fx-models");
|
|
8
8
|
const shared_1 = require("./shared");
|
|
9
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
9
10
|
function registerStaticFileMiddleware(server) {
|
|
10
|
-
server.middlewares.use(function (req, res, next) {
|
|
11
|
-
if (req.url.indexOf('/
|
|
11
|
+
server.middlewares.use(async function (req, res, next) {
|
|
12
|
+
if (req.url.indexOf('/api/uxdocs') === 0) {
|
|
13
|
+
if (req.method === "OPTIONS") {
|
|
14
|
+
res.end("OK");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const rawReqToString = async (req) => {
|
|
18
|
+
const buffers = [];
|
|
19
|
+
for await (const chunk of req) {
|
|
20
|
+
buffers.push(chunk);
|
|
21
|
+
}
|
|
22
|
+
return Buffer.concat(buffers).toString();
|
|
23
|
+
};
|
|
24
|
+
const jsonString = await rawReqToString(req);
|
|
25
|
+
const jsonObject = JSON.parse(jsonString);
|
|
26
|
+
const fileUrl = `wwwroot/docs/${jsonObject.relativePath}`;
|
|
27
|
+
console.log(fileUrl);
|
|
28
|
+
const content = fs_1.default.readFileSync(fileUrl, 'utf8');
|
|
29
|
+
res.end(content);
|
|
30
|
+
}
|
|
31
|
+
else if (req.url.indexOf('/omnia/fonts/') === 0 || req.url.indexOf('/omnia/images/') === 0) {
|
|
12
32
|
res.setHeader('Cache-Control', 'public, max-age=31536000');
|
|
13
33
|
req.url = req.url.replace("/omnia/", "/omnia/dist/");
|
|
14
34
|
next();
|
|
15
35
|
}
|
|
16
36
|
else if (req.url.indexOf('/omnia/bundles') === 0) {
|
|
17
37
|
// format: /omnia/bundles/{manifestId}/{bundleType}?{queryString}
|
|
18
|
-
let fullpath = req.
|
|
38
|
+
let fullpath = req.url.toLowerCase();
|
|
19
39
|
// format: /omnia/bundles/{manifestId}/{bundleType}
|
|
20
40
|
let path = fullpath.split('?')[0];
|
|
21
41
|
// format: {queryString}
|
|
@@ -28,15 +48,16 @@ function registerStaticFileMiddleware(server) {
|
|
|
28
48
|
res.setHeader('content-type', 'application/x-javascript');
|
|
29
49
|
let localizeObject = $.composers.getLocalizations();
|
|
30
50
|
res.end(`
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
const OmniaContext = omniaWebpackJsonp["bb000000-0000-bbbb-0000-0000000000bb"]["a1602121-3070-4304-b4d8-0859e50c482b"]("5326a8ef-4e3c-49d6-b415-1ddf7fdcc830").OmniaContext;
|
|
52
|
+
const container = omniaWebpackJsonp["bb000000-0000-bbbb-0000-0000000000bb"]["` + fx_models_1.OmniaResourceManifests.FxCore.toString() + `"]("97786ea9-4861-48bd-8a57-eae9bbdb4892").ServiceContainer;
|
|
53
|
+
const omniaCtx = container.createInstance(OmniaContext);
|
|
54
|
+
const useLocalizationStore = omniaWebpackJsonp["bb000000-0000-bbbb-0000-0000000000bb"]["` + fx_models_1.OmniaResourceManifests.Fx.toString() + `"]("5e618f4d-d014-414e-a681-89e34cbeda0f").useLocalizationStore;
|
|
55
|
+
const localizeStore = container.createInstance(useLocalizationStore);
|
|
56
|
+
const currentCulture = omniaCtx.language.toLowerCase();
|
|
57
|
+
const loc = JSON.parse('${JSON.stringify(localizeObject).replace(/'/g, "\\'").replace(/\\"/g, "\\\\\"")}');
|
|
37
58
|
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
localizeStore.actions.merge(loc['en-us'] || {}); // add default english
|
|
60
|
+
localizeStore.actions.merge(loc[currentCulture] || {});
|
|
40
61
|
`);
|
|
41
62
|
}
|
|
42
63
|
else {
|
|
@@ -94,7 +94,7 @@ function registerWebpackMiddleWareBundle(entries) {
|
|
|
94
94
|
if (manifestId) {
|
|
95
95
|
let manifest = $.tooling.composer.getManifestById(manifestId);
|
|
96
96
|
if (manifest) {
|
|
97
|
-
let manifestsData = $.tooling.composer.
|
|
97
|
+
let manifestsData = $.tooling.composer.getManifestsJson();
|
|
98
98
|
let bundleType = path_1.default.extname(filePath).replace('.', '');
|
|
99
99
|
manifest.version = manifest.version || {};
|
|
100
100
|
manifest.version[bundleType] = $.tooling.utils.generateGuid().replace(/-/g, '');
|