@omnia/tooling-vue 8.0.23-vnext → 8.0.24-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/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 +2241 -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 -105
- package/internal-do-not-import-from-here/shared.js +97 -155
- package/internal-do-not-import-from-here/tasks/ComponentDocRegistrations.js +1 -1
- package/internal-do-not-import-from-here/tasks/bundle.d.ts +2 -3
- package/internal-do-not-import-from-here/tasks/bundle.js +168 -390
- 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/vendor.js +7 -3
- 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 +5 -1
- package/internal-do-not-import-from-here/vite/hmr/manifest.js +5 -5
- package/internal-do-not-import-from-here/vite/hmr/runtime.js +5 -5
- 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 +7 -6
- package/internal-do-not-import-from-here/vite/hmr/utils/webpack.js +2 -2
- package/internal-do-not-import-from-here/vite/middlewares/HmrMiddleware.js +5 -12
- package/internal-do-not-import-from-here/vite/middlewares/OmniaMiddleware.js +55 -17
- package/internal-do-not-import-from-here/vite/middlewares/StaticFileMiddleware.js +9 -8
- package/internal-do-not-import-from-here/vite/middlewares/WebpackMiddleware.js +1 -1
- package/internal-do-not-import-from-here/vite/plugins/OmniaPlugin.js +9 -1
- 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/ts-loader.d.ts +10 -3
- package/internal-do-not-import-from-here/webpack-loaders/ts-loader.js +11 -4
- package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.d.ts +10 -0
- package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.js +12 -2
- 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 +10 -7
- package/internal-do-not-import-from-here/bb000000-0000-bbbb-0000-0000000000bb.wctypings.d.ts +0 -423
- 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/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/{bb000000-0000-bbbb-0000-0000000000bb.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,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addDependency = exports.processManifestGenerated = exports.checkDuplicateBundle = exports.
|
|
3
|
+
exports.addDependency = exports.processManifestGenerated = exports.checkDuplicateBundle = exports.registerManifestsReference = exports.createCombinedManfest = exports.createVueWebpackConfig = exports.cleanUpComposer = exports.getBuildOption = exports.getServiceId = exports.bundleManifest = exports.ensureManifestDependencyInRuntime = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
6
|
const del_1 = tslib_1.__importDefault(require("del"));
|
|
7
7
|
const fsExtra = tslib_1.__importStar(require("fs-extra"));
|
|
8
|
-
const
|
|
8
|
+
const globby_1 = require("globby");
|
|
9
9
|
const terser_1 = require("terser");
|
|
10
10
|
const ts_loader_1 = tslib_1.__importDefault(require("../webpack-loaders/ts-loader"));
|
|
11
11
|
const tsx_loader_1 = tslib_1.__importDefault(require("../webpack-loaders/tsx-loader"));
|
|
@@ -14,13 +14,13 @@ const fx_models_1 = require("@omnia/fx-models");
|
|
|
14
14
|
const $ = tslib_1.__importStar(require("../variables"));
|
|
15
15
|
const shared_1 = require("../shared");
|
|
16
16
|
const tooling_1 = require("@omnia/tooling");
|
|
17
|
-
const
|
|
17
|
+
const doc_1 = require("./doc");
|
|
18
18
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
19
19
|
const ConcatSource = require('webpack-core/lib/ConcatSource');
|
|
20
20
|
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
|
21
21
|
const isEqual = require('lodash/isEqual');
|
|
22
22
|
const vendorProdId = "aaf89b2d-5ea8-4b79-946a-8c1e89f713a3";
|
|
23
|
-
let outDirManifestMetadata = "client/tooling/vue/output_manifests", _manifestsEntry = {}, _registeredReferenceManifests = [], serviceId = null, _modulesStats = {}, _manifestsStats = {}, keepTrackbuildOptions = {}, _transformResourcepaths = []
|
|
23
|
+
let outDirManifestMetadata = "client/tooling/vue/output_manifests", _manifestsEntry = {}, _registeredReferenceManifests = [], serviceId = null, _modulesStats = {}, _manifestsStats = {}, keepTrackbuildOptions = {}, _transformResourcepaths = [];
|
|
24
24
|
if ($.isExtensionEnv) {
|
|
25
25
|
outDirManifestMetadata = "node_modules/@omnia/tooling-vue/internal-do-not-import-from-here/output_manifests";
|
|
26
26
|
}
|
|
@@ -40,19 +40,24 @@ $.tooling.core.registerBuildTask({
|
|
|
40
40
|
return new Promise(function (resolve, reject) {
|
|
41
41
|
buildEntries()
|
|
42
42
|
.then((result) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
if (process.argv.length > 0 && process.argv.find(argv => argv === "--package") !== undefined) {
|
|
44
|
+
resolve(result);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
let startTime = new Date().getTime();
|
|
48
|
+
tooling_1.utils.log("Typescript checking...");
|
|
49
|
+
const spawn = require("child_process").spawn;
|
|
50
|
+
spawn("node", [path_1.default.resolve(__dirname, "./tsc.js")], { stdio: "inherit", })
|
|
51
|
+
.on('exit', (code) => {
|
|
52
|
+
if (code == 0) {
|
|
53
|
+
tooling_1.utils.logTime('Done - Typescript', startTime);
|
|
54
|
+
resolve(result);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
process.exit(code);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
56
61
|
}, reject);
|
|
57
62
|
});
|
|
58
63
|
}
|
|
@@ -186,42 +191,38 @@ function clean() {
|
|
|
186
191
|
return new Promise(function (resolve, reject) {
|
|
187
192
|
del_1.default.sync("node_modules/.cache");
|
|
188
193
|
del_1.default.sync($.tooling.utils.root(outDirManifestMetadata + "/manifest.entries.cached.json"));
|
|
189
|
-
|
|
190
|
-
del_1.default.sync($.path.resolve(__dirname, "../wctypings.ts"));
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
del_1.default.sync($.path.resolve(__dirname, `../bb000000-0000-bbbb-0000-0000000000bb.wctypings.ts`));
|
|
194
|
-
}
|
|
194
|
+
shared_1.ConfigurationManager.webComponentTypings.delete();
|
|
195
195
|
resolve();
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
function buildEntries(serve = false) {
|
|
199
199
|
return new Promise(async function (resolve, reject) {
|
|
200
200
|
try {
|
|
201
|
-
|
|
201
|
+
let startTime = new Date().getTime();
|
|
202
202
|
var componentRegistry = $.composers.ComponentRegistry;
|
|
203
203
|
let componentRegistrations = componentRegistry.getRegistrations();
|
|
204
204
|
const serviceInfo = $.composers.ServiceManifestRegistry.getServiceInfo();
|
|
205
|
+
startTime = new Date().getTime();
|
|
206
|
+
$.tooling.logTime("Found [" + componentRegistrations.length + "] component registrations", startTime);
|
|
207
|
+
let componentEntries = createVueEntryFormComponentRegistrations(componentRegistrations);
|
|
205
208
|
if (serviceInfo.serviceType === tooling_composers_1.ServiceTypes.WebApp) {
|
|
206
|
-
await generateComponentTypingsAndDoc(componentRegistrations);
|
|
209
|
+
await (0, doc_1.generateComponentTypingsAndDoc)(componentRegistrations);
|
|
207
210
|
}
|
|
208
|
-
$.tooling.logTime("Found [" + componentRegistrations.length + "] component registrations", startTime);
|
|
209
211
|
var resourceRegistry = $.composers.ResourceRegistry;
|
|
210
212
|
let resourceBundlesWithBuildOptions = resourceRegistry.getRegisteredResourceBundles(shared_1.convertManifestPathToEntryPath);
|
|
211
|
-
$.tooling.logTime("Found [" +
|
|
213
|
+
$.tooling.logTime("Found [" + resourceBundlesWithBuildOptions?.size + "] resource bundles", startTime);
|
|
212
214
|
let resourceEntries = {};
|
|
213
|
-
for (
|
|
214
|
-
let resource =
|
|
215
|
-
let manifest = $.composers.LoadableManifestRegistry.getRegisteredManifest(
|
|
215
|
+
for (const res of resourceBundlesWithBuildOptions) {
|
|
216
|
+
let resource = res[1];
|
|
217
|
+
let manifest = $.composers.LoadableManifestRegistry.getRegisteredManifest(res[0]);
|
|
216
218
|
if (!resource.buildOptions) {
|
|
217
|
-
resourceEntries[`${manifest.resourceName ? manifest.resourceName + "_" : ""}${
|
|
219
|
+
resourceEntries[`${manifest.resourceName ? manifest.resourceName + "_" : ""}${res[0]}`] = resource.paths;
|
|
218
220
|
}
|
|
219
221
|
else {
|
|
220
222
|
//Some special handling of buildoptions
|
|
221
|
-
console.log("debug " +
|
|
223
|
+
console.log("debug " + res[0] + " has build options for paths " + resource.paths + " buildoptions: " + JSON.stringify(resource.buildOptions));
|
|
222
224
|
}
|
|
223
225
|
}
|
|
224
|
-
let componentEntries = createVueEntryFormRegistrations(componentRegistrations);
|
|
225
226
|
var entries = $.merge(componentEntries, resourceEntries);
|
|
226
227
|
if (checkDuplicateWebpackEntryPoints(entries)) {
|
|
227
228
|
$.tooling.log('Build manifests metadata have error that found duplicated resource path', $.tooling.LogTypes.Error);
|
|
@@ -256,231 +257,6 @@ function buildEntries(serve = false) {
|
|
|
256
257
|
}
|
|
257
258
|
});
|
|
258
259
|
}
|
|
259
|
-
async function generateComponentTypingsAndDoc(componentRegistrations) {
|
|
260
|
-
tooling_1.utils.log("Generate components typings and documentation running...");
|
|
261
|
-
var startTime = new Date().getTime();
|
|
262
|
-
let DefineVueType;
|
|
263
|
-
(function (DefineVueType) {
|
|
264
|
-
DefineVueType[DefineVueType["Prop"] = 0] = "Prop";
|
|
265
|
-
DefineVueType[DefineVueType["Model"] = 1] = "Model";
|
|
266
|
-
DefineVueType[DefineVueType["Slot"] = 2] = "Slot";
|
|
267
|
-
DefineVueType[DefineVueType["Emit"] = 4] = "Emit";
|
|
268
|
-
})(DefineVueType || (DefineVueType = {}));
|
|
269
|
-
const docResult = {};
|
|
270
|
-
function getPropertyFunctionTypeAsString(type) {
|
|
271
|
-
let params = "";
|
|
272
|
-
if (type.params?.length > 0) {
|
|
273
|
-
type.params.forEach(p => {
|
|
274
|
-
params += `${p.value}:${getPropertyType(p.typeAnnotation)}, `;
|
|
275
|
-
});
|
|
276
|
-
params = params.replace(/,\s*$/, "");
|
|
277
|
-
}
|
|
278
|
-
return `(${params}) => ${getPropertyType(type.typeAnnotation)}`;
|
|
279
|
-
}
|
|
280
|
-
function getPropertyType(tsType) {
|
|
281
|
-
let result = "";
|
|
282
|
-
if (tsType.type === "TsTypeAnnotation") {
|
|
283
|
-
return getPropertyType(tsType.typeAnnotation);
|
|
284
|
-
}
|
|
285
|
-
switch (tsType.type) {
|
|
286
|
-
case "TsLiteralType":
|
|
287
|
-
result = tsType.literal.value;
|
|
288
|
-
break;
|
|
289
|
-
case "TsKeywordType":
|
|
290
|
-
result = tsType.kind;
|
|
291
|
-
break;
|
|
292
|
-
case "TsTypeReference":
|
|
293
|
-
result = tsType.typeName.value;
|
|
294
|
-
break;
|
|
295
|
-
case "TsFunctionType":
|
|
296
|
-
result = getPropertyFunctionTypeAsString(tsType);
|
|
297
|
-
break;
|
|
298
|
-
default:
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
return result;
|
|
302
|
-
}
|
|
303
|
-
function getNameProperty(ce, result) {
|
|
304
|
-
const identifier = ce.callee?.property?.value;
|
|
305
|
-
if (identifier) {
|
|
306
|
-
switch (identifier) {
|
|
307
|
-
case "name":
|
|
308
|
-
result.name = ce.arguments[0].expression.value;
|
|
309
|
-
getNameProperty(ce.callee.object, result);
|
|
310
|
-
break;
|
|
311
|
-
case "vModel":
|
|
312
|
-
result.type = DefineVueType.Model;
|
|
313
|
-
result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
|
|
314
|
-
result.name = result.name ? `v-model:${result.name}` : result.name;
|
|
315
|
-
break;
|
|
316
|
-
case "slots":
|
|
317
|
-
result.type = DefineVueType.Slot;
|
|
318
|
-
result.propertyTypeAsObject = {};
|
|
319
|
-
ce.typeArguments.params[0].members
|
|
320
|
-
.forEach(m => {
|
|
321
|
-
result.propertyTypeAsObject[m.key.value] = getPropertyType(m.typeAnnotation);
|
|
322
|
-
});
|
|
323
|
-
break;
|
|
324
|
-
case "prop":
|
|
325
|
-
// console.log(
|
|
326
|
-
// ce.typeArguments.params[0],
|
|
327
|
-
// ce.typeArguments.params[0].typeAnnotation?.typeAnnotation,
|
|
328
|
-
// )
|
|
329
|
-
result.type = DefineVueType.Prop;
|
|
330
|
-
result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
|
|
331
|
-
break;
|
|
332
|
-
case "emit":
|
|
333
|
-
result.type = DefineVueType.Emit;
|
|
334
|
-
result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
|
|
335
|
-
break;
|
|
336
|
-
default:
|
|
337
|
-
getNameProperty(ce.callee.object, result);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
async function buildDoc(wc) {
|
|
342
|
-
try {
|
|
343
|
-
const wcPath = (0, shared_1.convertManifestPathToEntryPath)(wc.manifestPath, [wc.componentOptions.entryPoint])[0];
|
|
344
|
-
const wcParseResult = await (0, core_1.parseFile)(wcPath, {
|
|
345
|
-
syntax: 'typescript',
|
|
346
|
-
target: 'es2020',
|
|
347
|
-
tsx: true,
|
|
348
|
-
decorators: true,
|
|
349
|
-
dynamicImport: true
|
|
350
|
-
});
|
|
351
|
-
wcParseResult.body.forEach(b => {
|
|
352
|
-
if (b.type === 'ExportDefaultExpression'
|
|
353
|
-
&& b.expression.callee?.value === "defineVueWebComponent") {
|
|
354
|
-
b.expression.arguments[0].expression
|
|
355
|
-
.properties?.filter(p => p.key.value === "props"
|
|
356
|
-
|| p.key.value === "emits")
|
|
357
|
-
?.forEach(propsIdentifier => {
|
|
358
|
-
if (propsIdentifier) {
|
|
359
|
-
propsIdentifier.value
|
|
360
|
-
.properties?.forEach(p => {
|
|
361
|
-
const em = p.arguments;
|
|
362
|
-
if (em?.callee?.property?.value === "doc$") {
|
|
363
|
-
const PropertyResult = {
|
|
364
|
-
type: null,
|
|
365
|
-
propertyTypeAsString: "",
|
|
366
|
-
name: ""
|
|
367
|
-
};
|
|
368
|
-
getNameProperty(em, PropertyResult);
|
|
369
|
-
if (!docResult[wc.componentOptions.elementName]) {
|
|
370
|
-
docResult[wc.componentOptions.elementName] = {
|
|
371
|
-
emits: {},
|
|
372
|
-
models: {},
|
|
373
|
-
props: {},
|
|
374
|
-
slots: {}
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
switch (PropertyResult.type) {
|
|
378
|
-
case DefineVueType.Prop:
|
|
379
|
-
docResult[wc.componentOptions.elementName].props[PropertyResult.name] = {
|
|
380
|
-
type: PropertyResult.propertyTypeAsString,
|
|
381
|
-
description: em.arguments[0].expression.value
|
|
382
|
-
};
|
|
383
|
-
break;
|
|
384
|
-
case DefineVueType.Model:
|
|
385
|
-
docResult[wc.componentOptions.elementName].models[PropertyResult.name] = {
|
|
386
|
-
type: PropertyResult.propertyTypeAsString,
|
|
387
|
-
description: em.arguments[0].expression.value
|
|
388
|
-
};
|
|
389
|
-
break;
|
|
390
|
-
case DefineVueType.Emit:
|
|
391
|
-
docResult[wc.componentOptions.elementName].emits[PropertyResult.name] = {
|
|
392
|
-
type: PropertyResult.propertyTypeAsString,
|
|
393
|
-
description: em.arguments[0].expression.value
|
|
394
|
-
};
|
|
395
|
-
break;
|
|
396
|
-
case DefineVueType.Slot:
|
|
397
|
-
em.arguments[0].expression
|
|
398
|
-
.properties
|
|
399
|
-
.forEach(p => {
|
|
400
|
-
const slotName = p.key.value;
|
|
401
|
-
docResult[wc.componentOptions.elementName].slots[slotName] = {
|
|
402
|
-
type: PropertyResult.propertyTypeAsObject[slotName],
|
|
403
|
-
description: p.value.value
|
|
404
|
-
};
|
|
405
|
-
});
|
|
406
|
-
break;
|
|
407
|
-
default:
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
catch (ex) {
|
|
418
|
-
tooling_1.utils.log(`Have a exception when extract doc$ for web component manifest -> ${wc.manifestPath}`, tooling_1.utils.LogTypes.Error);
|
|
419
|
-
console.error(ex);
|
|
420
|
-
throw new Error("Exit, have an exception.");
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
let wcTypingsPath = "", docPath = $.path.resolve(__dirname, "ComponentDocRegistrations.ts");
|
|
424
|
-
;
|
|
425
|
-
if ($.isExtensionEnv) {
|
|
426
|
-
wcTypingsPath = $.path.resolve(__dirname, "../wctypings.ts");
|
|
427
|
-
}
|
|
428
|
-
else {
|
|
429
|
-
wcTypingsPath = $.path.resolve(__dirname, `../${getServiceId().toLowerCase()}.wctypings.ts`);
|
|
430
|
-
}
|
|
431
|
-
let wcTypings = `
|
|
432
|
-
//{{importWC}}
|
|
433
|
-
declare global {
|
|
434
|
-
namespace JSX {
|
|
435
|
-
interface Element { }
|
|
436
|
-
interface ElementClass { }
|
|
437
|
-
|
|
438
|
-
interface IntrinsicElements {
|
|
439
|
-
//{{elementName}}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
`;
|
|
444
|
-
if ($.isExtensionEnv) {
|
|
445
|
-
wcTypings = `import { VueComponentBaseProps } from "@omnia/fx/ux";
|
|
446
|
-
${wcTypings}`;
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
wcTypings = `import { VueComponentBaseProps } from "../../../client/fx/ux/index";
|
|
450
|
-
${wcTypings}`;
|
|
451
|
-
}
|
|
452
|
-
await tooling_1.utils.asyncForEach(componentRegistrations, async (wc) => {
|
|
453
|
-
wcTypings = generateWebComponentTypings(wc, wcTypings);
|
|
454
|
-
await buildDoc(wc);
|
|
455
|
-
});
|
|
456
|
-
if (Object.keys(docResult).length > 0) {
|
|
457
|
-
fsExtra.outputFileSync(docPath, `
|
|
458
|
-
import { extendApi } from "@omnia/fx";
|
|
459
|
-
import { ComponentDoc } from "@omnia/fx-models";
|
|
460
|
-
|
|
461
|
-
extendApi(api => api.fx.docs.registrations, api => {
|
|
462
|
-
|
|
463
|
-
const registrations: { [elementName: string]: ComponentDoc } = ${JSON.stringify(docResult)}
|
|
464
|
-
|
|
465
|
-
Object.keys(registrations).forEach(elementName => {
|
|
466
|
-
api.register(elementName, registrations[elementName]);
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
`);
|
|
470
|
-
// create dynamic doc manifest
|
|
471
|
-
$.composers.ManifestRegistry.setCurrentManifestPath(`${path_1.default.relative(tooling_1.utils.root(""), path_1.default.resolve(__dirname))}/`);
|
|
472
|
-
$.composers
|
|
473
|
-
.Composer
|
|
474
|
-
.registerManifest(getBuildOption().dynamicDocManifestId || new fx_models_1.Guid(`${tooling_1.utils.generateGuid()}`), "omnia.fx.docs.components.registraions")
|
|
475
|
-
.registerResources({
|
|
476
|
-
resourcePaths: ["./ComponentDocRegistrations.ts"]
|
|
477
|
-
})
|
|
478
|
-
.extendApi(api => api.fx.docs.registrations);
|
|
479
|
-
$.composers.ManifestRegistry.setCurrentManifestPath();
|
|
480
|
-
}
|
|
481
|
-
fsExtra.outputFileSync(wcTypingsPath, wcTypings);
|
|
482
|
-
tooling_1.utils.logTime('Done - Generate components typings and documentation', startTime);
|
|
483
|
-
}
|
|
484
260
|
function buildManifestMetadatas(entries) {
|
|
485
261
|
return new Promise(function (resolve, reject) {
|
|
486
262
|
try {
|
|
@@ -576,14 +352,14 @@ function beforeBundleManifest(entries) {
|
|
|
576
352
|
// cleanup before generate
|
|
577
353
|
del_1.default.sync(outDirManifestMetadata);
|
|
578
354
|
const entriesToBuild = {};
|
|
579
|
-
const resourceRegistrations =
|
|
580
|
-
const wcRegistrations =
|
|
355
|
+
const resourceRegistrations = Array.from($.composers.ResourceRegistry.getResourceRegistrations().keys());
|
|
356
|
+
const wcRegistrations = $.composers.ComponentRegistry.getComponentRegistrations();
|
|
581
357
|
Object.keys(entries).forEach(name => {
|
|
582
|
-
if (resourceRegistrations.find(rk => name.indexOf(rk) > -1)) {
|
|
358
|
+
if (resourceRegistrations.find(rk => name.indexOf(rk.toString()) > -1)) {
|
|
583
359
|
entriesToBuild[name] = entries[name];
|
|
584
360
|
}
|
|
585
361
|
// generate manifest metadata for wc
|
|
586
|
-
else if (wcRegistrations.find(rk => name.indexOf(rk) > -1)) {
|
|
362
|
+
else if (wcRegistrations.find(rk => name.indexOf(rk.manifest.resourceId.toString()) > -1)) {
|
|
587
363
|
const manifestPath = $.tooling.utils.root(outDirManifestMetadata + "/" + name + '.manifest.json');
|
|
588
364
|
const content = {
|
|
589
365
|
name: `omniaWebpackJsonp['${getServiceId()}']['${$.tooling.utils.getGuidValue(name)}']`,
|
|
@@ -613,7 +389,6 @@ function beforeBundleManifest(entries) {
|
|
|
613
389
|
});
|
|
614
390
|
}
|
|
615
391
|
function bundleManifest(entries) {
|
|
616
|
-
var startTime = new Date().getTime();
|
|
617
392
|
return new Promise(function (resolve, reject) {
|
|
618
393
|
try {
|
|
619
394
|
// Hacky solution to delete node_modules inside tiptap regarding miss match version prosemirror
|
|
@@ -655,14 +430,18 @@ function bundleManifest(entries) {
|
|
|
655
430
|
}
|
|
656
431
|
else {
|
|
657
432
|
let webpackConfigs = [];
|
|
433
|
+
var startTime = new Date().getTime();
|
|
434
|
+
// $.tooling.logTime('Build Webpack Config running', startTime);
|
|
658
435
|
Object.keys(entries).forEach((id) => {
|
|
659
436
|
var entry = {};
|
|
660
437
|
entry[id] = entries[id];
|
|
661
438
|
var vueWebpackConfig = createVueWebpackConfig(entry, entries, $.tooling.composer.OmniaOutput.OutputBundlePath);
|
|
662
439
|
webpackConfigs.push(vueWebpackConfig);
|
|
663
440
|
});
|
|
441
|
+
// $.tooling.logTime('Build Webpack Config - done', startTime);
|
|
664
442
|
let compiler = $.webpack(webpackConfigs);
|
|
665
443
|
compiler.run((err, stats) => {
|
|
444
|
+
//console.log("webpack run -done")
|
|
666
445
|
if (checkDuplicateBundle()) { // detect duplicated bundle
|
|
667
446
|
$.tooling.log('Bundle manifest have error that found duplicated bundles', $.tooling.LogTypes.Error);
|
|
668
447
|
reject();
|
|
@@ -744,7 +523,7 @@ function minifyBundles() {
|
|
|
744
523
|
if (process.argv.length > 0 && process.argv.find(argv => argv === "--minify") !== undefined) {
|
|
745
524
|
let startTime = new Date().getTime();
|
|
746
525
|
$.tooling.log('Minify bundles running...');
|
|
747
|
-
const jsPaths =
|
|
526
|
+
const jsPaths = (0, globby_1.globbySync)([`${$.tooling.utils.root($.tooling.composer.OmniaOutput.OutputBundlePath)}/*.js`]);
|
|
748
527
|
let promises = [];
|
|
749
528
|
jsPaths.forEach(filePath => {
|
|
750
529
|
promises.push(new Promise(async (resolve, reject) => {
|
|
@@ -785,7 +564,7 @@ function minifyBundles() {
|
|
|
785
564
|
}
|
|
786
565
|
});
|
|
787
566
|
}
|
|
788
|
-
function createVueWebpackConfig(currentEntry, entries, bundleOutputDir,
|
|
567
|
+
function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, viteHmrOption) {
|
|
789
568
|
let buildOption = getBuildOption() || {};
|
|
790
569
|
let isBundleCommonChunk = buildOption.bundleOptions && buildOption.bundleOptions.commonsChunk && buildOption.bundleOptions.commonsChunk.name;
|
|
791
570
|
const extractCss = new MiniCssExtractPlugin({
|
|
@@ -890,7 +669,7 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, hotModul
|
|
|
890
669
|
mangleExports: false,
|
|
891
670
|
concatenateModules: true,
|
|
892
671
|
//moduleIds: 'natural' as any
|
|
893
|
-
}, isBundleCommonChunk ? buildCommonChunk(entry) : {}),
|
|
672
|
+
}, isBundleCommonChunk && !viteHmrOption ? buildCommonChunk(entry) : {}),
|
|
894
673
|
resolve: {
|
|
895
674
|
modules: $.tooling.core.getWebpackResolveModules(),
|
|
896
675
|
extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.html', '.vue', '.less', '.styl'],
|
|
@@ -1052,7 +831,7 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, hotModul
|
|
|
1052
831
|
exports.createVueWebpackConfig = createVueWebpackConfig;
|
|
1053
832
|
function createWebpackConfigForManifestMetadata(entry, metadataOutputDir) {
|
|
1054
833
|
var entensionId = getServiceId();
|
|
1055
|
-
return Object.assign({},
|
|
834
|
+
return Object.assign({}, getBaseWebpackConfigForManifestMetadata(entry, metadataOutputDir), {
|
|
1056
835
|
plugins: [
|
|
1057
836
|
...buildReferenceManifestFromConfig(),
|
|
1058
837
|
new $.omniaWebpackPlugins.NamedModulesPlugin(buildModuleName()),
|
|
@@ -1064,6 +843,117 @@ function createWebpackConfigForManifestMetadata(entry, metadataOutputDir) {
|
|
|
1064
843
|
]
|
|
1065
844
|
});
|
|
1066
845
|
}
|
|
846
|
+
function getBaseWebpackConfigForManifestMetadata(entry, bundleOutputDir) {
|
|
847
|
+
return {
|
|
848
|
+
devtool: false,
|
|
849
|
+
mode: 'development',
|
|
850
|
+
context: $.tooling.utils.root(""),
|
|
851
|
+
entry: entry,
|
|
852
|
+
optimization: Object.assign({
|
|
853
|
+
removeAvailableModules: false,
|
|
854
|
+
removeEmptyChunks: false,
|
|
855
|
+
splitChunks: false,
|
|
856
|
+
}),
|
|
857
|
+
resolve: {
|
|
858
|
+
modules: $.tooling.core.getWebpackResolveModules(),
|
|
859
|
+
extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'],
|
|
860
|
+
//extensions: ['.js', '.jsx', '.ts', '.tsx', '.html', '.vue', '.less', '.styl'],
|
|
861
|
+
symlinks: false,
|
|
862
|
+
cacheWithContext: true,
|
|
863
|
+
descriptionFiles: ['package.json'],
|
|
864
|
+
alias: Object.assign({}, $.tooling.core.getWebpackResolveAlias(), ($.composers.BuildConfigurationRegistry.getBuildOptions()?.moduleOptions?.alias || {}), {
|
|
865
|
+
'axios$': 'axios/dist/axios.js',
|
|
866
|
+
'typestyle$': 'typestyle/lib.es2015/index.js',
|
|
867
|
+
'vue$': 'vue/dist/vue.runtime.esm-bundler.js',
|
|
868
|
+
'@microsoft/signalr': '@microsoft/signalr/dist/webworker/signalr.js',
|
|
869
|
+
}),
|
|
870
|
+
//mainFields: ['main', 'browser', 'module']
|
|
871
|
+
},
|
|
872
|
+
output: {
|
|
873
|
+
pathinfo: false,
|
|
874
|
+
path: $.tooling.utils.root(bundleOutputDir),
|
|
875
|
+
filename: '[name].js'
|
|
876
|
+
},
|
|
877
|
+
externals: [
|
|
878
|
+
function ({ context, request }, callback) {
|
|
879
|
+
if (request.indexOf("node_modules") > -1 || (/\.(sass|scss|styl|less|css)$/i).test(request)) {
|
|
880
|
+
return callback(null, 'commonjs ' + request);
|
|
881
|
+
}
|
|
882
|
+
callback();
|
|
883
|
+
}
|
|
884
|
+
],
|
|
885
|
+
module: {
|
|
886
|
+
noParse: /wwwroot(.*)/,
|
|
887
|
+
rules: [
|
|
888
|
+
{
|
|
889
|
+
test: /\.m?js$/,
|
|
890
|
+
resolve: {
|
|
891
|
+
fullySpecified: false, // disable the behaviour
|
|
892
|
+
},
|
|
893
|
+
},
|
|
894
|
+
...(0, ts_loader_1.default)(),
|
|
895
|
+
...(0, tsx_loader_1.default)(),
|
|
896
|
+
{
|
|
897
|
+
test: /\.styl$/,
|
|
898
|
+
use: [
|
|
899
|
+
//'style-loader',
|
|
900
|
+
//'css-loader',
|
|
901
|
+
'stylus-loader'
|
|
902
|
+
]
|
|
903
|
+
},
|
|
904
|
+
...($.isExtensionEnv ? [] : [{
|
|
905
|
+
test: /\.s(c|a)ss$/,
|
|
906
|
+
use: [
|
|
907
|
+
{
|
|
908
|
+
loader: 'sass-loader',
|
|
909
|
+
options: {
|
|
910
|
+
implementation: require('sass'),
|
|
911
|
+
sassOptions: {
|
|
912
|
+
//fiber: require('fibers'),
|
|
913
|
+
indentedSyntax: true
|
|
914
|
+
}
|
|
915
|
+
//fiber: require('fibers')
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
]
|
|
919
|
+
}]),
|
|
920
|
+
{
|
|
921
|
+
test: /\.less$/,
|
|
922
|
+
use: [
|
|
923
|
+
//'style-loader',
|
|
924
|
+
//'css-loader',
|
|
925
|
+
'less-loader'
|
|
926
|
+
]
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
test: /\.css$/,
|
|
930
|
+
use: [
|
|
931
|
+
//'style-loader',
|
|
932
|
+
{
|
|
933
|
+
loader: 'css-loader'
|
|
934
|
+
}
|
|
935
|
+
]
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
|
939
|
+
loader: 'url-loader'
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
test: /\.(ico|gif|png|jpe?g|svg)$/i,
|
|
943
|
+
use: [{
|
|
944
|
+
loader: 'file-loader',
|
|
945
|
+
options: {
|
|
946
|
+
name: '[name].[ext]',
|
|
947
|
+
outputPath: "../images/",
|
|
948
|
+
publicPath: '/omnia/images/'
|
|
949
|
+
}
|
|
950
|
+
}]
|
|
951
|
+
//loader: 'url-loader'
|
|
952
|
+
}
|
|
953
|
+
]
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
}
|
|
1067
957
|
function buildCommonChunk(entry) {
|
|
1068
958
|
let bundleOptions = getBuildOption().bundleOptions;
|
|
1069
959
|
let minChunk = bundleOptions.commonsChunk.minChunks || 2;
|
|
@@ -1099,7 +989,7 @@ function buildCommonChunk(entry) {
|
|
|
1099
989
|
function processManifestGenerated(entries, outDir) {
|
|
1100
990
|
var allowJsOutputExtensions = [".js", ".ts", ".tsx", ".jsx", ".vue"];
|
|
1101
991
|
if (entries) {
|
|
1102
|
-
var manifestsPaths =
|
|
992
|
+
var manifestsPaths = (0, globby_1.globbySync)(outDir.replace(/\/$/, '') + '/*.*', {});
|
|
1103
993
|
if (manifestsPaths) {
|
|
1104
994
|
for (let p of manifestsPaths) {
|
|
1105
995
|
var manifestId = $.tooling.utils.getGuidValue($.tooling.utils.getFileName(p));
|
|
@@ -1430,89 +1320,18 @@ function getServiceId() {
|
|
|
1430
1320
|
return serviceId;
|
|
1431
1321
|
}
|
|
1432
1322
|
exports.getServiceId = getServiceId;
|
|
1433
|
-
function
|
|
1434
|
-
let foundTypes = {};
|
|
1435
|
-
componentRegistrations.forEach((comp) => {
|
|
1436
|
-
let defPaths = comp.componentOptions.typings;
|
|
1437
|
-
if (defPaths) {
|
|
1438
|
-
let isChildSpec = false;
|
|
1439
|
-
defPaths.forEach((defPath) => {
|
|
1440
|
-
let entryPointPath = (0, shared_1.convertManifestPathToEntryPath)(comp.manifestPath, [defPath])[0];
|
|
1441
|
-
let contents = $.fs.readFileSync(entryPointPath, 'utf8');
|
|
1442
|
-
let wcEl = getWcElement(contents, isChildSpec);
|
|
1443
|
-
if (wcEl) {
|
|
1444
|
-
//Now lets find the interface mapped to element
|
|
1445
|
-
//example /*@WebComponentInterface("omfx-dialog")*/
|
|
1446
|
-
let interfaceToken = `/*@WebComponentInterface("${wcEl}")*/`;
|
|
1447
|
-
let interfaceIndex = contents.indexOf(interfaceToken);
|
|
1448
|
-
if (interfaceIndex > -1) {
|
|
1449
|
-
let wcProps = [];
|
|
1450
|
-
let intf = contents.substring(interfaceIndex);
|
|
1451
|
-
let nextIsDomProp = false;
|
|
1452
|
-
intf = intf
|
|
1453
|
-
.substring(intf.indexOf("{") + 1, intf.indexOf("}"))
|
|
1454
|
-
.replace(/\?/g, '')
|
|
1455
|
-
.trim()
|
|
1456
|
-
.split(/\r\n|\r|\n/g).forEach((group) => {
|
|
1457
|
-
/*@DomProperty*/
|
|
1458
|
-
let sub = group.trim();
|
|
1459
|
-
if (sub.indexOf("/*@DomProperty*/") > -1) {
|
|
1460
|
-
nextIsDomProp = true;
|
|
1461
|
-
return;
|
|
1462
|
-
}
|
|
1463
|
-
if (nextIsDomProp) {
|
|
1464
|
-
if (sub.indexOf(':')) {
|
|
1465
|
-
sub = sub.split(':')[0];
|
|
1466
|
-
}
|
|
1467
|
-
if (sub) {
|
|
1468
|
-
if (!foundTypes[wcEl]) {
|
|
1469
|
-
foundTypes[wcEl] = [];
|
|
1470
|
-
}
|
|
1471
|
-
foundTypes[wcEl].push(sub);
|
|
1472
|
-
}
|
|
1473
|
-
nextIsDomProp = false;
|
|
1474
|
-
}
|
|
1475
|
-
});
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
isChildSpec = true;
|
|
1479
|
-
});
|
|
1480
|
-
}
|
|
1481
|
-
});
|
|
1482
|
-
return foundTypes;
|
|
1483
|
-
}
|
|
1484
|
-
var lastWcElement = "";
|
|
1485
|
-
function getWcElement(contents, isChildSpec) {
|
|
1486
|
-
if (isChildSpec) {
|
|
1487
|
-
if (lastWcElement === "") {
|
|
1488
|
-
new Error("Cant find the /*@DomProperty*/ on the parent interface for the WebComponent definition");
|
|
1489
|
-
}
|
|
1490
|
-
return lastWcElement;
|
|
1491
|
-
}
|
|
1492
|
-
else {
|
|
1493
|
-
lastWcElement = "";
|
|
1494
|
-
}
|
|
1495
|
-
let wcElToken = "/*@WebComponent*/";
|
|
1496
|
-
let wcElIndex = contents.indexOf(wcElToken);
|
|
1497
|
-
let wcEl = "";
|
|
1498
|
-
if (wcElIndex > -1) {
|
|
1499
|
-
wcEl = contents.substring(wcElIndex);
|
|
1500
|
-
wcEl = wcEl.substring(wcEl.indexOf('"') + 1);
|
|
1501
|
-
wcEl = wcEl.substring(0, wcEl.indexOf('"'));
|
|
1502
|
-
lastWcElement = wcEl;
|
|
1503
|
-
}
|
|
1504
|
-
return lastWcElement;
|
|
1505
|
-
}
|
|
1506
|
-
function createVueEntryFormRegistrations(registrations) {
|
|
1323
|
+
function createVueEntryFormComponentRegistrations(registrations) {
|
|
1507
1324
|
let entryPaths = {};
|
|
1508
1325
|
for (let r of registrations) {
|
|
1509
|
-
if (r.componentOptions.entryPoint.endsWith('.
|
|
1326
|
+
if (r.componentOptions.entryPoint.endsWith('.tsx')
|
|
1327
|
+
|| r.componentOptions.entryPoint.endsWith('.vue')) {
|
|
1510
1328
|
let entryPointPath = (0, shared_1.convertManifestPathToEntryPath)(r.manifestPath, [r.componentOptions.entryPoint]);
|
|
1511
1329
|
let entryId = r.manifest.resourceId;
|
|
1512
1330
|
if (r.manifest.resourceName) {
|
|
1513
1331
|
entryId = `${r.manifest.resourceName}_${entryId}`;
|
|
1514
1332
|
}
|
|
1515
|
-
|
|
1333
|
+
r.componentOptions.entryPointPath = entryPointPath[0];
|
|
1334
|
+
entryPaths[entryId.toString()] = entryPointPath;
|
|
1516
1335
|
}
|
|
1517
1336
|
else {
|
|
1518
1337
|
$.tooling.log('The OmniaFx build system only supports .jsx, .vue and .tsx based components at the moment ', $.tooling.LogTypes.Error);
|
|
@@ -1523,7 +1342,6 @@ function createVueEntryFormRegistrations(registrations) {
|
|
|
1523
1342
|
}
|
|
1524
1343
|
function ensureManifestDependencyInRuntime(currentManifestId, manifestBundleFilePath) {
|
|
1525
1344
|
let manifest = $.tooling.composer.getManifestById(currentManifestId);
|
|
1526
|
-
let hasChanged = false;
|
|
1527
1345
|
const content = fsExtra.readFileSync(manifestBundleFilePath, 'utf8');
|
|
1528
1346
|
const addDependency = (dependOnmanifestId, dependOnServiceId) => {
|
|
1529
1347
|
let hasNewDependency = false;
|
|
@@ -1547,7 +1365,7 @@ function ensureManifestDependencyInRuntime(currentManifestId, manifestBundleFile
|
|
|
1547
1365
|
if (manifestObject && manifestObject.content) {
|
|
1548
1366
|
Object.keys(manifestObject.content).forEach((modulePath) => {
|
|
1549
1367
|
if (content.indexOf(modulePath) > -1) {
|
|
1550
|
-
|
|
1368
|
+
addDependency(manifest.resourceId, manifest.serviceId);
|
|
1551
1369
|
return;
|
|
1552
1370
|
}
|
|
1553
1371
|
});
|
|
@@ -1580,7 +1398,7 @@ function ensureManifestDependencyInRuntime(currentManifestId, manifestBundleFile
|
|
|
1580
1398
|
hasDependency = true;
|
|
1581
1399
|
}
|
|
1582
1400
|
if (hasDependency) {
|
|
1583
|
-
|
|
1401
|
+
addDependency($.tooling.utils.getGuidValue(entryName));
|
|
1584
1402
|
break;
|
|
1585
1403
|
}
|
|
1586
1404
|
}
|
|
@@ -1588,10 +1406,6 @@ function ensureManifestDependencyInRuntime(currentManifestId, manifestBundleFile
|
|
|
1588
1406
|
}
|
|
1589
1407
|
});
|
|
1590
1408
|
}
|
|
1591
|
-
if (hasChanged) {
|
|
1592
|
-
let manifestsData = $.tooling.composer.getManifestData();
|
|
1593
|
-
$.tooling.composer.updateManifestData(manifestsData);
|
|
1594
|
-
}
|
|
1595
1409
|
}
|
|
1596
1410
|
exports.ensureManifestDependencyInRuntime = ensureManifestDependencyInRuntime;
|
|
1597
1411
|
function buildManifestsDependency(entries, manifestId, manifestBundleContent) {
|
|
@@ -1682,15 +1496,12 @@ function chunkAsset(entries, compilation, fileName, viteHmrOption) {
|
|
|
1682
1496
|
/******/ }
|
|
1683
1497
|
/******/ omniaLoader['${omniaServiceId}'] = omniaLoader['${omniaServiceId}'] || {};
|
|
1684
1498
|
/******/
|
|
1685
|
-
/******/ function
|
|
1499
|
+
/******/ function hmrPreBundle() {
|
|
1686
1500
|
${content}
|
|
1687
1501
|
/******/ }
|
|
1688
1502
|
|
|
1689
|
-
if (omniaLoader['${omniaServiceId}']['${manifestId}']){
|
|
1690
|
-
omniaLoader['${omniaServiceId}']['${manifestId}']
|
|
1691
|
-
}
|
|
1692
|
-
else {
|
|
1693
|
-
omniaLoader['${omniaServiceId}']['${manifestId}'] = preBundle;
|
|
1503
|
+
if (!omniaLoader['${omniaServiceId}']['${manifestId}']){
|
|
1504
|
+
omniaLoader['${omniaServiceId}']['${manifestId}'] = hmrPreBundle;
|
|
1694
1505
|
}`;
|
|
1695
1506
|
}
|
|
1696
1507
|
else if (viteHmrOption == 'dynamic') {
|
|
@@ -1834,42 +1645,9 @@ exports.registerManifestsReference = registerManifestsReference;
|
|
|
1834
1645
|
function getRegisteredReferenceManifests() {
|
|
1835
1646
|
return _registeredReferenceManifests;
|
|
1836
1647
|
}
|
|
1837
|
-
function registerWebComponentDefinitions(definitions) {
|
|
1838
|
-
if (definitions) {
|
|
1839
|
-
_wcDefinitions = $.merge(_wcDefinitions, definitions);
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
exports.registerWebComponentDefinitions = registerWebComponentDefinitions;
|
|
1843
1648
|
function sortString(a, b) {
|
|
1844
1649
|
if (a >= b) {
|
|
1845
1650
|
return 1;
|
|
1846
1651
|
}
|
|
1847
1652
|
return -1;
|
|
1848
1653
|
}
|
|
1849
|
-
function generateWebComponentTypings(wc, template) {
|
|
1850
|
-
// export default defineVueWebComponent
|
|
1851
|
-
let wcPath = (0, shared_1.convertManifestPathToEntryPath)(wc.manifestPath, [wc.componentOptions.entryPoint])[0];
|
|
1852
|
-
let content = fsExtra.readFileSync(wcPath, 'utf8');
|
|
1853
|
-
if (content.indexOf("defineVueWebComponent") > -1) {
|
|
1854
|
-
if (!new RegExp('export\\s+default\\s+').test(content)) {
|
|
1855
|
-
throw new Error(`Missing statement 'export default a vue web component' in ${wcPath}`);
|
|
1856
|
-
}
|
|
1857
|
-
let friendlyManifestId = `wc${wc.manifest.resourceId.replace(/-/g, '').toLowerCase()}`;
|
|
1858
|
-
let importPath = wcPath.substring(0, wcPath.lastIndexOf('.tsx'));
|
|
1859
|
-
if (importPath.indexOf("./") === 0) {
|
|
1860
|
-
importPath = importPath.replace("./", "");
|
|
1861
|
-
}
|
|
1862
|
-
if ($.isExtensionEnv) {
|
|
1863
|
-
importPath = `../../../../${importPath}`;
|
|
1864
|
-
}
|
|
1865
|
-
else {
|
|
1866
|
-
importPath = `../../../${importPath}`;
|
|
1867
|
-
}
|
|
1868
|
-
return template
|
|
1869
|
-
.replace(/\/\/{{importWC}}/, `import ${friendlyManifestId} from '${importPath}';
|
|
1870
|
-
//{{importWC}}`)
|
|
1871
|
-
.replace(/\/\/{{elementName}}/, `"${wc.componentOptions.elementName}": typeof ${friendlyManifestId}.propsDefinition & VueComponentBaseProps
|
|
1872
|
-
//{{elementName}}`);
|
|
1873
|
-
}
|
|
1874
|
-
return template;
|
|
1875
|
-
}
|