@omnia/tooling-vue 8.0.63-vnext → 8.0.64-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.
Files changed (32) hide show
  1. package/internal-do-not-import-from-here/config/omnia.vendor.manifest.json +1 -1
  2. package/internal-do-not-import-from-here/config/tooling.output.json +1 -0
  3. package/internal-do-not-import-from-here/config/wctypings.d.ts +2549 -0
  4. package/internal-do-not-import-from-here/index.d.ts +3 -1
  5. package/internal-do-not-import-from-here/index.js +6 -2
  6. package/internal-do-not-import-from-here/shared.d.ts +31 -118
  7. package/internal-do-not-import-from-here/shared.js +95 -153
  8. package/internal-do-not-import-from-here/tasks/ComponentDocRegistrations.js +1 -1
  9. package/internal-do-not-import-from-here/tasks/bundle.d.ts +1 -2
  10. package/internal-do-not-import-from-here/tasks/bundle.js +144 -359
  11. package/internal-do-not-import-from-here/tasks/doc.d.ts +3 -1
  12. package/internal-do-not-import-from-here/tasks/doc.js +282 -395
  13. package/internal-do-not-import-from-here/tasks/vendor.js +9 -7
  14. package/internal-do-not-import-from-here/variables.d.ts +1 -1
  15. package/internal-do-not-import-from-here/variables.js +2 -2
  16. package/internal-do-not-import-from-here/vite/hmr/graph.js +4 -0
  17. package/internal-do-not-import-from-here/vite/plugins/OmniaPlugin.js +1 -1
  18. package/internal-do-not-import-from-here/wctypings.ts +0 -0
  19. package/internal-do-not-import-from-here/webpack-loaders/doc-loader.js +11 -0
  20. package/internal-do-not-import-from-here/webpack-loaders/ts-loader.d.ts +3 -3
  21. package/internal-do-not-import-from-here/webpack-loaders/ts-loader.js +3 -3
  22. package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.d.ts +3 -0
  23. package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.js +3 -0
  24. package/internal-do-not-import-from-here/webpack-loaders/wc-loader.d.ts +1 -0
  25. package/internal-do-not-import-from-here/webpack-loaders/wc-loader.js +11 -0
  26. package/package.json +4 -3
  27. package/internal-do-not-import-from-here/bb000000-0000-bbbb-0000-0000000000bb.wctypings.d.ts +0 -493
  28. package/internal-do-not-import-from-here/webpack-loaders/esbuild-custom-loader.js +0 -13
  29. package/internal-do-not-import-from-here/webpack-loaders/wcmanifest-loader.d.ts +0 -1
  30. package/internal-do-not-import-from-here/webpack-loaders/wcmanifest-loader.js +0 -10
  31. /package/internal-do-not-import-from-here/{bb000000-0000-bbbb-0000-0000000000bb.wctypings.js → config/wctypings.js} +0 -0
  32. /package/internal-do-not-import-from-here/webpack-loaders/{esbuild-custom-loader.d.ts → doc-loader.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addDependency = exports.processManifestGenerated = exports.checkDuplicateBundle = exports.registerWebComponentDefinitions = exports.registerManifestsReference = exports.createCombinedManfest = exports.createVueWebpackConfig = exports.cleanUpComposer = exports.getBuildOption = exports.getServiceId = exports.bundleManifest = exports.ensureManifestDependencyInRuntime = void 0;
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"));
@@ -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 core_1 = require("@swc/core");
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 = [], _wcDefinitions = {};
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
- let startTime = new Date().getTime();
44
- tooling_1.utils.log("Typescript checking...");
45
- const spawn = require("child_process").spawn;
46
- spawn("node", [path_1.default.resolve(__dirname, "./tsc.js")], { stdio: "inherit", })
47
- .on('exit', (code) => {
48
- if (code == 0) {
49
- tooling_1.utils.logTime('Done - Typescript', startTime);
50
- resolve(result);
51
- }
52
- else {
53
- process.exit(code);
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,12 +191,7 @@ 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
- if ($.isExtensionEnv) {
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
  }
@@ -202,11 +202,12 @@ function buildEntries(serve = false) {
202
202
  var componentRegistry = $.composers.ComponentRegistry;
203
203
  let componentRegistrations = componentRegistry.getRegistrations();
204
204
  const serviceInfo = $.composers.ServiceManifestRegistry.getServiceInfo();
205
- if (serviceInfo.serviceType === tooling_composers_1.ServiceTypes.WebApp) {
206
- await generateComponentTypingsAndDoc(componentRegistrations);
207
- }
208
205
  startTime = new Date().getTime();
209
206
  $.tooling.logTime("Found [" + componentRegistrations.length + "] component registrations", startTime);
207
+ let componentEntries = createVueEntryFormComponentRegistrations(componentRegistrations);
208
+ if (serviceInfo.serviceType === tooling_composers_1.ServiceTypes.WebApp) {
209
+ await (0, doc_1.generateComponentTypingsAndDoc)(componentRegistrations);
210
+ }
210
211
  var resourceRegistry = $.composers.ResourceRegistry;
211
212
  let resourceBundlesWithBuildOptions = resourceRegistry.getRegisteredResourceBundles(shared_1.convertManifestPathToEntryPath);
212
213
  $.tooling.logTime("Found [" + resourceBundlesWithBuildOptions?.size + "] resource bundles", startTime);
@@ -222,7 +223,6 @@ function buildEntries(serve = false) {
222
223
  console.log("debug " + res[0] + " has build options for paths " + resource.paths + " buildoptions: " + JSON.stringify(resource.buildOptions));
223
224
  }
224
225
  }
225
- let componentEntries = createVueEntryFormRegistrations(componentRegistrations);
226
226
  var entries = $.merge(componentEntries, resourceEntries);
227
227
  if (checkDuplicateWebpackEntryPoints(entries)) {
228
228
  $.tooling.log('Build manifests metadata have error that found duplicated resource path', $.tooling.LogTypes.Error);
@@ -257,228 +257,6 @@ function buildEntries(serve = false) {
257
257
  }
258
258
  });
259
259
  }
260
- async function generateComponentTypingsAndDoc(componentRegistrations) {
261
- tooling_1.utils.log("Generate components typings and documentation running...");
262
- var startTime = new Date().getTime();
263
- let DefineVueType;
264
- (function (DefineVueType) {
265
- DefineVueType[DefineVueType["Prop"] = 0] = "Prop";
266
- DefineVueType[DefineVueType["Model"] = 1] = "Model";
267
- DefineVueType[DefineVueType["Slot"] = 2] = "Slot";
268
- DefineVueType[DefineVueType["Emit"] = 4] = "Emit";
269
- })(DefineVueType || (DefineVueType = {}));
270
- const docResult = {};
271
- function getPropertyFunctionTypeAsString(type) {
272
- let params = "";
273
- if (type.params?.length > 0) {
274
- type.params.forEach(p => {
275
- params += `${p.value}:${getPropertyType(p.typeAnnotation)}, `;
276
- });
277
- params = params.replace(/,\s*$/, "");
278
- }
279
- return `(${params}) => ${getPropertyType(type.typeAnnotation)}`;
280
- }
281
- function getPropertyType(tsType) {
282
- let result = "";
283
- if (tsType.type === "TsTypeAnnotation") {
284
- return getPropertyType(tsType.typeAnnotation);
285
- }
286
- switch (tsType.type) {
287
- case "TsLiteralType":
288
- result = tsType.literal.value;
289
- break;
290
- case "TsKeywordType":
291
- result = tsType.kind;
292
- break;
293
- case "TsTypeReference":
294
- result = tsType.typeName.value;
295
- break;
296
- case "TsFunctionType":
297
- result = getPropertyFunctionTypeAsString(tsType);
298
- break;
299
- default:
300
- break;
301
- }
302
- return result;
303
- }
304
- function getNameProperty(ce, result) {
305
- const identifier = ce.callee?.property?.value;
306
- if (identifier) {
307
- switch (identifier) {
308
- case "name":
309
- result.name = ce.arguments[0].expression.value;
310
- getNameProperty(ce.callee.object, result);
311
- break;
312
- case "vModel":
313
- result.type = DefineVueType.Model;
314
- result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
315
- result.name = result.name ? `v-model:${result.name}` : result.name;
316
- break;
317
- case "slots":
318
- result.type = DefineVueType.Slot;
319
- result.propertyTypeAsObject = {};
320
- ce.typeArguments.params[0].members
321
- .forEach(m => {
322
- result.propertyTypeAsObject[m.key.value] = getPropertyType(m.typeAnnotation);
323
- });
324
- break;
325
- case "prop":
326
- result.type = DefineVueType.Prop;
327
- result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
328
- break;
329
- case "emit":
330
- result.type = DefineVueType.Emit;
331
- result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
332
- break;
333
- default:
334
- getNameProperty(ce.callee.object, result);
335
- }
336
- }
337
- }
338
- async function buildDoc(wc) {
339
- try {
340
- const wcPath = (0, shared_1.convertManifestPathToEntryPath)(wc.manifestPath, [wc.componentOptions.entryPoint])[0];
341
- const wcParseResult = await (0, core_1.parseFile)(wcPath, {
342
- syntax: 'typescript',
343
- target: 'es2020',
344
- tsx: true,
345
- decorators: true,
346
- dynamicImport: true
347
- });
348
- wcParseResult.body.forEach(b => {
349
- if (b.type === 'ExportDefaultExpression'
350
- && b.expression.callee?.value === "defineVueWebComponent") {
351
- b.expression.arguments[0].expression
352
- .properties?.filter(p => p.key.value === "props"
353
- || p.key.value === "emits")
354
- ?.forEach(propsIdentifier => {
355
- if (propsIdentifier) {
356
- propsIdentifier.value
357
- .properties?.forEach(p => {
358
- const em = p.arguments;
359
- if (em?.callee?.property?.value === "doc$") {
360
- const PropertyResult = {
361
- type: null,
362
- propertyTypeAsString: "",
363
- name: ""
364
- };
365
- getNameProperty(em, PropertyResult);
366
- if (!docResult[wc.componentOptions.elementName]) {
367
- docResult[wc.componentOptions.elementName] = {
368
- emits: {},
369
- models: {},
370
- props: {},
371
- slots: {}
372
- };
373
- }
374
- switch (PropertyResult.type) {
375
- case DefineVueType.Prop:
376
- docResult[wc.componentOptions.elementName].props[PropertyResult.name] = {
377
- type: PropertyResult.propertyTypeAsString,
378
- description: em.arguments[0].expression.value
379
- };
380
- break;
381
- case DefineVueType.Model:
382
- docResult[wc.componentOptions.elementName].models[PropertyResult.name] = {
383
- type: PropertyResult.propertyTypeAsString,
384
- description: em.arguments[0].expression.value
385
- };
386
- break;
387
- case DefineVueType.Emit:
388
- docResult[wc.componentOptions.elementName].emits[PropertyResult.name] = {
389
- type: PropertyResult.propertyTypeAsString,
390
- description: em.arguments[0].expression.value
391
- };
392
- break;
393
- case DefineVueType.Slot:
394
- em.arguments[0].expression
395
- .properties
396
- .forEach(p => {
397
- const slotName = p.key.value;
398
- docResult[wc.componentOptions.elementName].slots[slotName] = {
399
- type: PropertyResult.propertyTypeAsObject[slotName],
400
- description: p.value.value
401
- };
402
- });
403
- break;
404
- default:
405
- break;
406
- }
407
- }
408
- });
409
- }
410
- });
411
- }
412
- });
413
- }
414
- catch (ex) {
415
- tooling_1.utils.log(`Have a exception when extract doc$ for web component manifest -> ${wc.manifestPath}`, tooling_1.utils.LogTypes.Error);
416
- console.error(ex);
417
- throw new Error("Exit, have an exception.");
418
- }
419
- }
420
- let wcTypingsPath = "", docPath = $.path.resolve(__dirname, "ComponentDocRegistrations.ts");
421
- ;
422
- if ($.isExtensionEnv) {
423
- wcTypingsPath = $.path.resolve(__dirname, "../wctypings.ts");
424
- }
425
- else {
426
- wcTypingsPath = $.path.resolve(__dirname, `../${getServiceId().toLowerCase()}.wctypings.ts`);
427
- }
428
- let wcTypings = `
429
- //{{importWC}}
430
- declare global {
431
- namespace JSX {
432
- interface Element { }
433
- interface ElementClass { }
434
-
435
- interface IntrinsicElements {
436
- //{{elementName}}
437
- }
438
- }
439
- }
440
- `;
441
- if ($.isExtensionEnv) {
442
- wcTypings = `import { VueComponentBaseProps } from "@omnia/fx/ux";
443
- ${wcTypings}`;
444
- }
445
- else {
446
- wcTypings = `import { VueComponentBaseProps } from "../../../client/fx/ux/index";
447
- ${wcTypings}`;
448
- }
449
- await tooling_1.utils.asyncForEach(componentRegistrations, async (wc) => {
450
- wcTypings = generateWebComponentTypings(wc, wcTypings);
451
- await buildDoc(wc);
452
- });
453
- if (Object.keys(docResult).length > 0) {
454
- fsExtra.outputFileSync(docPath, `
455
- import { extendApi } from "@omnia/fx";
456
- import { ComponentDoc } from "@omnia/fx-models";
457
-
458
- extendApi(api => api.fx.docs.registrations, api => {
459
-
460
- const registrations: { [elementName: string]: ComponentDoc } = ${JSON.stringify(docResult)}
461
-
462
- Object.keys(registrations).forEach(elementName => {
463
- api.register(elementName, registrations[elementName]);
464
- });
465
- });
466
- `);
467
- // create dynamic doc manifest
468
- $.composers.ManifestRegistry.setCurrentManifestPath(`${path_1.default.relative(tooling_1.utils.root(""), path_1.default.resolve(__dirname))}/`);
469
- $.composers
470
- .Composer
471
- .registerManifest(getBuildOption().dynamicDocManifestId || new fx_models_1.Guid(`${tooling_1.utils.generateGuid()}`), "omnia.fx.docs.components.registraions")
472
- .registerResources({
473
- resourcePaths: ["./ComponentDocRegistrations.ts"]
474
- })
475
- .withTarget(fx_models_1.ClientManifestTargetTypes.Docs)
476
- .extendApi(api => api.fx.docs.registrations);
477
- $.composers.ManifestRegistry.setCurrentManifestPath();
478
- }
479
- fsExtra.outputFileSync(wcTypingsPath, wcTypings);
480
- tooling_1.utils.logTime('Done - Generate components typings and documentation', startTime);
481
- }
482
260
  function buildManifestMetadatas(entries) {
483
261
  return new Promise(function (resolve, reject) {
484
262
  try {
@@ -905,7 +683,7 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, viteHmrO
905
683
  '@microsoft/signalr$': '@microsoft/signalr/dist/webworker/signalr.js',
906
684
  }),
907
685
  },
908
- target: ['web', 'es2022'],
686
+ target: ['web', 'es2022'], // Will change ES6 when stop support IE11
909
687
  output: {
910
688
  //library: {
911
689
  // type: "umd"
@@ -1053,7 +831,7 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, viteHmrO
1053
831
  exports.createVueWebpackConfig = createVueWebpackConfig;
1054
832
  function createWebpackConfigForManifestMetadata(entry, metadataOutputDir) {
1055
833
  var entensionId = getServiceId();
1056
- return Object.assign({}, (0, shared_1.getBaseWebpackConfigForManifestMetadata)(entry, metadataOutputDir), {
834
+ return Object.assign({}, getBaseWebpackConfigForManifestMetadata(entry, metadataOutputDir), {
1057
835
  plugins: [
1058
836
  ...buildReferenceManifestFromConfig(),
1059
837
  new $.omniaWebpackPlugins.NamedModulesPlugin(buildModuleName()),
@@ -1065,6 +843,117 @@ function createWebpackConfigForManifestMetadata(entry, metadataOutputDir) {
1065
843
  ]
1066
844
  });
1067
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
+ }
1068
957
  function buildCommonChunk(entry) {
1069
958
  let bundleOptions = getBuildOption().bundleOptions;
1070
959
  let minChunk = bundleOptions.commonsChunk.minChunks || 2;
@@ -1431,89 +1320,18 @@ function getServiceId() {
1431
1320
  return serviceId;
1432
1321
  }
1433
1322
  exports.getServiceId = getServiceId;
1434
- function extractTypingsForComponents(componentRegistrations) {
1435
- let foundTypes = {};
1436
- componentRegistrations.forEach((comp) => {
1437
- let defPaths = comp.componentOptions.typings;
1438
- if (defPaths) {
1439
- let isChildSpec = false;
1440
- defPaths.forEach((defPath) => {
1441
- let entryPointPath = (0, shared_1.convertManifestPathToEntryPath)(comp.manifestPath, [defPath])[0];
1442
- let contents = $.fs.readFileSync(entryPointPath, 'utf8');
1443
- let wcEl = getWcElement(contents, isChildSpec);
1444
- if (wcEl) {
1445
- //Now lets find the interface mapped to element
1446
- //example /*@WebComponentInterface("omfx-dialog")*/
1447
- let interfaceToken = `/*@WebComponentInterface("${wcEl}")*/`;
1448
- let interfaceIndex = contents.indexOf(interfaceToken);
1449
- if (interfaceIndex > -1) {
1450
- let wcProps = [];
1451
- let intf = contents.substring(interfaceIndex);
1452
- let nextIsDomProp = false;
1453
- intf = intf
1454
- .substring(intf.indexOf("{") + 1, intf.indexOf("}"))
1455
- .replace(/\?/g, '')
1456
- .trim()
1457
- .split(/\r\n|\r|\n/g).forEach((group) => {
1458
- /*@DomProperty*/
1459
- let sub = group.trim();
1460
- if (sub.indexOf("/*@DomProperty*/") > -1) {
1461
- nextIsDomProp = true;
1462
- return;
1463
- }
1464
- if (nextIsDomProp) {
1465
- if (sub.indexOf(':')) {
1466
- sub = sub.split(':')[0];
1467
- }
1468
- if (sub) {
1469
- if (!foundTypes[wcEl]) {
1470
- foundTypes[wcEl] = [];
1471
- }
1472
- foundTypes[wcEl].push(sub);
1473
- }
1474
- nextIsDomProp = false;
1475
- }
1476
- });
1477
- }
1478
- }
1479
- isChildSpec = true;
1480
- });
1481
- }
1482
- });
1483
- return foundTypes;
1484
- }
1485
- var lastWcElement = "";
1486
- function getWcElement(contents, isChildSpec) {
1487
- if (isChildSpec) {
1488
- if (lastWcElement === "") {
1489
- new Error("Cant find the /*@DomProperty*/ on the parent interface for the WebComponent definition");
1490
- }
1491
- return lastWcElement;
1492
- }
1493
- else {
1494
- lastWcElement = "";
1495
- }
1496
- let wcElToken = "/*@WebComponent*/";
1497
- let wcElIndex = contents.indexOf(wcElToken);
1498
- let wcEl = "";
1499
- if (wcElIndex > -1) {
1500
- wcEl = contents.substring(wcElIndex);
1501
- wcEl = wcEl.substring(wcEl.indexOf('"') + 1);
1502
- wcEl = wcEl.substring(0, wcEl.indexOf('"'));
1503
- lastWcElement = wcEl;
1504
- }
1505
- return lastWcElement;
1506
- }
1507
- function createVueEntryFormRegistrations(registrations) {
1323
+ function createVueEntryFormComponentRegistrations(registrations) {
1508
1324
  let entryPaths = {};
1509
1325
  for (let r of registrations) {
1510
- if (r.componentOptions.entryPoint.endsWith('.jsx') || r.componentOptions.entryPoint.endsWith('.vue') || r.componentOptions.entryPoint.endsWith('.tsx') || r.componentOptions.entryPoint.endsWith('.ts')) {
1326
+ if (r.componentOptions.entryPoint.endsWith('.tsx')
1327
+ || r.componentOptions.entryPoint.endsWith('.vue')) {
1511
1328
  let entryPointPath = (0, shared_1.convertManifestPathToEntryPath)(r.manifestPath, [r.componentOptions.entryPoint]);
1512
1329
  let entryId = r.manifest.resourceId;
1513
1330
  if (r.manifest.resourceName) {
1514
1331
  entryId = `${r.manifest.resourceName}_${entryId}`;
1515
1332
  }
1516
- entryPaths[entryId] = entryPointPath;
1333
+ r.componentOptions.entryPointPath = entryPointPath[0];
1334
+ entryPaths[entryId.toString()] = entryPointPath;
1517
1335
  }
1518
1336
  else {
1519
1337
  $.tooling.log('The OmniaFx build system only supports .jsx, .vue and .tsx based components at the moment ', $.tooling.LogTypes.Error);
@@ -1827,42 +1645,9 @@ exports.registerManifestsReference = registerManifestsReference;
1827
1645
  function getRegisteredReferenceManifests() {
1828
1646
  return _registeredReferenceManifests;
1829
1647
  }
1830
- function registerWebComponentDefinitions(definitions) {
1831
- if (definitions) {
1832
- _wcDefinitions = $.merge(_wcDefinitions, definitions);
1833
- }
1834
- }
1835
- exports.registerWebComponentDefinitions = registerWebComponentDefinitions;
1836
1648
  function sortString(a, b) {
1837
1649
  if (a >= b) {
1838
1650
  return 1;
1839
1651
  }
1840
1652
  return -1;
1841
1653
  }
1842
- function generateWebComponentTypings(wc, template) {
1843
- // export default defineVueWebComponent
1844
- let wcPath = (0, shared_1.convertManifestPathToEntryPath)(wc.manifestPath, [wc.componentOptions.entryPoint])[0];
1845
- let content = fsExtra.readFileSync(wcPath, 'utf8');
1846
- if (content.indexOf("defineVueWebComponent") > -1) {
1847
- if (!new RegExp('export\\s+default\\s+').test(content)) {
1848
- throw new Error(`Missing statement 'export default a vue web component' in ${wcPath}`);
1849
- }
1850
- let friendlyManifestId = `wc${wc.manifest.resourceId.toString().replace(/-/g, '').toLowerCase()}`;
1851
- let importPath = wcPath.substring(0, wcPath.lastIndexOf('.tsx'));
1852
- if (importPath.indexOf("./") === 0) {
1853
- importPath = importPath.replace("./", "");
1854
- }
1855
- if ($.isExtensionEnv) {
1856
- importPath = `../../../../${importPath}`;
1857
- }
1858
- else {
1859
- importPath = `../../../${importPath}`;
1860
- }
1861
- return template
1862
- .replace(/\/\/{{importWC}}/, `import ${friendlyManifestId} from '${importPath}';
1863
- //{{importWC}}`)
1864
- .replace(/\/\/{{elementName}}/, `"${wc.componentOptions.elementName}": typeof ${friendlyManifestId}.propsDefinition & VueComponentBaseProps
1865
- //{{elementName}}`);
1866
- }
1867
- return template;
1868
- }
@@ -1 +1,3 @@
1
- export {};
1
+ import { ComponentRegistration } from "@omnia/tooling-composers";
2
+ export declare function generateComponentTypingsAndDoc(componentRegistrations: ComponentRegistration[]): Promise<void>;
3
+ export declare function importSnippetCode(content: string, filePath: string): string;