@omnia/tooling-vue 8.0.115-vnext → 8.0.116-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 (30) hide show
  1. package/internal-do-not-import-from-here/config/omnia.fx.core_a2892051-fd9f-4056-ae8d-30d16d48417d.manifest.json +1 -0
  2. package/internal-do-not-import-from-here/config/omnia.fx.ux.libs_0fe5c5f2-8d89-485b-afd4-36fe3ff5943a.manifest.json +1 -0
  3. package/internal-do-not-import-from-here/config/omnia.fx.ux_dee030cc-4ab3-4158-bb06-8049f5c67542.manifest.json +1 -0
  4. package/internal-do-not-import-from-here/config/omnia.fx_a5a89056-b5f5-475d-8518-a1f55090379d.manifest.json +1 -0
  5. package/internal-do-not-import-from-here/config/omnia.vendor.manifest.json +1 -1
  6. package/internal-do-not-import-from-here/config/tooling.output.json +1 -1
  7. package/internal-do-not-import-from-here/config/wctypings.d.ts +4576 -1737
  8. package/internal-do-not-import-from-here/shared.d.ts +32 -10
  9. package/internal-do-not-import-from-here/shared.js +313 -26
  10. package/internal-do-not-import-from-here/tasks/ComponentDocRegistrations.js +1 -1
  11. package/internal-do-not-import-from-here/tasks/bundle.js +108 -33
  12. package/internal-do-not-import-from-here/tasks/doc.js +97 -182
  13. package/internal-do-not-import-from-here/tasks/vendor.js +17 -13
  14. package/internal-do-not-import-from-here/vite/hmr/graph.js +1 -1
  15. package/internal-do-not-import-from-here/vite/hmr/vueJsx.js +3 -2
  16. package/internal-do-not-import-from-here/vite/index.js +1 -1
  17. package/internal-do-not-import-from-here/vite/plugins/OmniaPlugin.js +1 -1
  18. package/internal-do-not-import-from-here/webpack-loaders/esbuild-custom-loader.d.ts +1 -0
  19. package/internal-do-not-import-from-here/webpack-loaders/esbuild-custom-loader.js +10 -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 -0
  22. package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.d.ts +3 -3
  23. package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.js +9 -3
  24. package/internal-do-not-import-from-here/webpack-loaders/{wc-loader.js → vue-component-loader.js} +1 -1
  25. package/internal-do-not-import-from-here/webpack-plugins/stylexjs/index.d.ts +53 -0
  26. package/internal-do-not-import-from-here/webpack-plugins/stylexjs/index.js +194 -0
  27. package/internal-do-not-import-from-here/webpack-plugins/stylexjs/loader.d.ts +9 -0
  28. package/internal-do-not-import-from-here/webpack-plugins/stylexjs/loader.js +23 -0
  29. package/package.json +9 -10
  30. /package/internal-do-not-import-from-here/webpack-loaders/{wc-loader.d.ts → vue-component-loader.d.ts} +0 -0
@@ -15,6 +15,7 @@ const $ = tslib_1.__importStar(require("../variables"));
15
15
  const shared_1 = require("../shared");
16
16
  const tooling_1 = require("@omnia/tooling");
17
17
  const doc_1 = require("./doc");
18
+ const stylexjs_1 = require("../webpack-plugins/stylexjs");
18
19
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
19
20
  const ConcatSource = require('webpack-core/lib/ConcatSource');
20
21
  const CircularDependencyPlugin = require('circular-dependency-plugin');
@@ -257,7 +258,7 @@ function buildEntries(serve = false) {
257
258
  }
258
259
  });
259
260
  }
260
- function buildManifestMetadatas(entries) {
261
+ function buildManifestMetadata(entries) {
261
262
  return new Promise(function (resolve, reject) {
262
263
  try {
263
264
  var startTime = new Date().getTime();
@@ -344,7 +345,7 @@ function beforeBundleManifest(entries) {
344
345
  // isRunBuildMetadata = !isEqual(entries, cachedEntries);
345
346
  // }
346
347
  // }
347
- if ($.fs.existsSync(cachedEntriesPath)) {
348
+ if (!isBuildWebpackManifestOnly() && $.fs.existsSync(cachedEntriesPath)) {
348
349
  let cachedEntries = require(cachedEntriesPath);
349
350
  isRunBuildMetadata = !isEqual(entries, cachedEntries);
350
351
  }
@@ -376,9 +377,15 @@ function beforeBundleManifest(entries) {
376
377
  fsExtra.writeJsonSync(manifestPath, content);
377
378
  }
378
379
  });
379
- buildManifestMetadatas(entriesToBuild).then(() => {
380
+ buildManifestMetadata(entriesToBuild).then(() => {
380
381
  fsExtra.ensureFileSync(cachedEntriesPath);
381
382
  fsExtra.writeJsonSync(cachedEntriesPath, entries);
383
+ if (isBuildWebpackManifestOnly()) {
384
+ fsExtra.copyFileSync(`${outDirManifestMetadata}/omnia.fx.core_a2892051-fd9f-4056-ae8d-30d16d48417d.manifest.json`, "client/tooling/vue/config/omnia.fx.core_a2892051-fd9f-4056-ae8d-30d16d48417d.manifest.json");
385
+ fsExtra.copyFileSync(`${outDirManifestMetadata}/omnia.fx_a5a89056-b5f5-475d-8518-a1f55090379d.manifest.json`, "client/tooling/vue/config/omnia.fx_a5a89056-b5f5-475d-8518-a1f55090379d.manifest.json");
386
+ fsExtra.copyFileSync(`${outDirManifestMetadata}/omnia.fx.ux_dee030cc-4ab3-4158-bb06-8049f5c67542.manifest.json`, "client/tooling/vue/config/omnia.fx.ux_dee030cc-4ab3-4158-bb06-8049f5c67542.manifest.json");
387
+ fsExtra.copyFileSync(`${outDirManifestMetadata}/omnia.fx.ux.libs_0fe5c5f2-8d89-485b-afd4-36fe3ff5943a.manifest.json`, "client/tooling/vue/config/omnia.fx.ux.libs_0fe5c5f2-8d89-485b-afd4-36fe3ff5943a.manifest.json");
388
+ }
382
389
  resolve(entries);
383
390
  });
384
391
  }
@@ -466,6 +473,21 @@ function bundleManifest(entries) {
466
473
  return;
467
474
  }
468
475
  compiler.close((err, result) => { });
476
+ // merge stylex.css
477
+ const stylexFiles = (0, globby_1.globbySync)([`${$.tooling.utils.root($.tooling.composer.OmniaOutput.OutputBundlePath).replace(/\\/g, "/")}/*.stylex.css`]);
478
+ stylexFiles?.forEach(stylexFilePath => {
479
+ const manifestCssFilePath = stylexFilePath.replace(".stylex.css", ".css");
480
+ const styelxCss = fsExtra.readFileSync(stylexFilePath, 'utf8');
481
+ if (!fsExtra.existsSync(manifestCssFilePath)) {
482
+ fsExtra.outputFileSync(manifestCssFilePath, styelxCss);
483
+ }
484
+ else {
485
+ const css = fsExtra.readFileSync(manifestCssFilePath, 'utf8');
486
+ fsExtra.outputFileSync(manifestCssFilePath, `${styelxCss}
487
+ ${css}`);
488
+ }
489
+ fsExtra.removeSync(stylexFilePath);
490
+ });
469
491
  resolve(entries);
470
492
  });
471
493
  }
@@ -518,12 +540,15 @@ function afterGenerateManifestsMetadata() {
518
540
  .then(resolve, reject);
519
541
  });
520
542
  }
543
+ function isBuildWebpackManifestOnly() {
544
+ return process.argv?.find(argv => argv === "--webpackManifest") !== undefined;
545
+ }
521
546
  function minifyBundles() {
522
547
  return new Promise(function (resolve, reject) {
523
548
  if (process.argv.length > 0 && process.argv.find(argv => argv === "--minify") !== undefined) {
524
549
  let startTime = new Date().getTime();
525
550
  $.tooling.log('Minify bundles running...');
526
- const jsPaths = (0, globby_1.globbySync)([`${$.tooling.utils.root($.tooling.composer.OmniaOutput.OutputBundlePath)}/*.js`]);
551
+ const jsPaths = (0, globby_1.globbySync)([`${$.tooling.utils.root($.tooling.composer.OmniaOutput.OutputBundlePath).replace(/\\/g, "/")}/*.js`]);
527
552
  let promises = [];
528
553
  jsPaths.forEach(filePath => {
529
554
  promises.push(new Promise(async (resolve, reject) => {
@@ -578,8 +603,27 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, viteHmrO
578
603
  process: { env: { NODE_ENV: JSON.stringify('production') } }
579
604
  }),
580
605
  ...referenceManifests,
581
- extractCss,
582
606
  new $.omniaWebpackPlugins.NamedModulesPlugin(buildModuleName()),
607
+ extractCss,
608
+ new stylexjs_1.StylexPlugin({
609
+ // filename: 'styles.[contenthash].css',
610
+ filename: `${Object.keys(entry)[0]}.stylex.css`,
611
+ // get webpack mode and set value for dev
612
+ dev: false,
613
+ // Use statically generated CSS files and not runtime injected CSS.
614
+ // Even in development.
615
+ runtimeInjection: false,
616
+ // optional. default: 'x'
617
+ classNamePrefix: 'o',
618
+ // Required for CSS variable support
619
+ unstable_moduleResolution: {
620
+ // type: 'commonJS' | 'haste'
621
+ // default: 'commonJS'
622
+ type: 'commonJS',
623
+ // The absolute path to the root directory of your project
624
+ rootDir: __dirname,
625
+ },
626
+ }),
583
627
  ];
584
628
  if (!buildOption.detectCircularDependencyOptions || buildOption.detectCircularDependencyOptions.disable !== true) {
585
629
  plugins.unshift(new CircularDependencyPlugin({
@@ -652,10 +696,10 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, viteHmrO
652
696
  plugins.push(new $.omniaWebpackPlugins.ChunkAssets(function (compilation, fileName) {
653
697
  chunkAsset(entries, compilation, fileName, viteHmrOption);
654
698
  }));
655
- let webpackEntries = {};
656
- Object.keys(entry).forEach(name => {
657
- webpackEntries[name] = { import: entry[name] };
658
- });
699
+ // let webpackEntries = {};
700
+ // Object.keys(entry).forEach(name => {
701
+ // webpackEntries[name] = { import: entry[name] }
702
+ // })
659
703
  return {
660
704
  mode: 'production',
661
705
  devtool: false,
@@ -683,7 +727,7 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, viteHmrO
683
727
  '@microsoft/signalr$': '@microsoft/signalr/dist/webworker/signalr.js',
684
728
  }),
685
729
  },
686
- target: ['web', 'es2022'],
730
+ target: ['web', 'es2022'], // Will change ES6 when stop support IE11
687
731
  output: {
688
732
  //library: {
689
733
  // type: "umd"
@@ -718,8 +762,8 @@ function createVueWebpackConfig(currentEntry, entries, bundleOutputDir, viteHmrO
718
762
  }
719
763
  return false;
720
764
  },
721
- // use: 'null-loader',
722
765
  use: [
766
+ // 'null-loader',
723
767
  {
724
768
  loader: path_1.default.resolve(__dirname, $.isExtensionEnv ? '../webpack-loaders/ingore-vuetify-locale.js' : '../webpack-loaders/ingore-vuetify-locale.ts'),
725
769
  }
@@ -833,7 +877,7 @@ function createWebpackConfigForManifestMetadata(entry, metadataOutputDir) {
833
877
  var entensionId = getServiceId();
834
878
  return Object.assign({}, getBaseWebpackConfigForManifestMetadata(entry, metadataOutputDir), {
835
879
  plugins: [
836
- ...buildReferenceManifestFromConfig(),
880
+ ...buildReferenceManifestFromConfig(Object.keys(entry)[0]),
837
881
  new $.omniaWebpackPlugins.NamedModulesPlugin(buildModuleName()),
838
882
  new $.webpack.DllPlugin({
839
883
  entryOnly: false,
@@ -1061,9 +1105,10 @@ function createCombinedManfest(omniaServiceId, manifestIds, targetManifestId, ta
1061
1105
  if (manifestIds &&
1062
1106
  targetManifestId &&
1063
1107
  manifestIds.length > 0) {
1064
- let manifestIdToFileNameMap = {};
1065
- let targetFileName = `${targetManifestName ? targetManifestName + "_" : ""}${targetManifestId}.js`;
1066
- manifestIdToFileNameMap[targetManifestId] = targetFileName;
1108
+ const manifestIdToFileNameMap = {};
1109
+ const targetJsFileName = `${targetManifestName ? targetManifestName + "_" : ""}${targetManifestId}.js`;
1110
+ const targetCssFileName = `${targetManifestName ? targetManifestName + "_" : ""}${targetManifestId}.css`;
1111
+ manifestIdToFileNameMap[targetManifestId] = targetJsFileName;
1067
1112
  $.tooling.log("Creating manifest group bundle [" + targetManifestId + "]", $.tooling.LogTypes.HeadLine);
1068
1113
  let omniaServiceId = getServiceId();
1069
1114
  manifestIds.sort((manifestId1, manifestId2) => {
@@ -1080,18 +1125,32 @@ function createCombinedManfest(omniaServiceId, manifestIds, targetManifestId, ta
1080
1125
  }
1081
1126
  return result;
1082
1127
  });
1083
- let bundleNames = [];
1128
+ const jsBundleNames = [];
1129
+ const cssBundleNames = [];
1084
1130
  for (let i = 0; i < manifestIds.length; i++) {
1085
1131
  let manifest = $.composers.LoadableManifestRegistry.getRegisteredManifest(manifestIds[i]);
1086
- bundleNames[i] = outputDir + `/${manifest.resourceName ? manifest.resourceName + "_" : ""}${manifest.resourceId}.js`;
1087
- if (!$.fs.existsSync(bundleNames[i])) {
1088
- throw new Error("Error, can't create combined bundle: " + targetFileName + " can't find bundle to include: " + bundleNames[i]);
1132
+ jsBundleNames[i] = outputDir + `/${manifest.resourceName ? manifest.resourceName + "_" : ""}${manifest.resourceId}.js`;
1133
+ const cssFilePath = outputDir + `/${manifest.resourceName ? manifest.resourceName + "_" : ""}${manifest.resourceId}.css`;
1134
+ if (!fsExtra.existsSync(jsBundleNames[i])) {
1135
+ throw new Error("Error, can't create combined bundle: " + targetJsFileName + " can't find bundle to include: " + jsBundleNames[i]);
1136
+ }
1137
+ if (fsExtra.existsSync(cssFilePath)) {
1138
+ cssBundleNames.push(cssFilePath);
1089
1139
  }
1090
- manifestIdToFileNameMap[manifestIds[i]] = bundleNames[i];
1140
+ manifestIdToFileNameMap[manifestIds[i]] = jsBundleNames[i];
1091
1141
  $.tooling.log("Adding manifest bundle [" + manifestIds[i] + "] to group", $.tooling.LogTypes.Info);
1092
1142
  }
1093
- let mergedContent = "";
1094
- bundleNames.forEach(filePath => {
1143
+ let mergedCssContent = "";
1144
+ cssBundleNames.forEach(filePath => {
1145
+ mergedCssContent = `${mergedCssContent}
1146
+ ${fsExtra.readFileSync(filePath, 'utf8')}
1147
+ `;
1148
+ });
1149
+ if (mergedCssContent) {
1150
+ fsExtra.writeFileSync(`${outputDir}/${targetCssFileName}`, mergedCssContent);
1151
+ }
1152
+ let mergedJsContent = "";
1153
+ jsBundleNames.forEach(filePath => {
1095
1154
  let manifestId = "";
1096
1155
  let currentFilename = $.path.basename(filePath);
1097
1156
  for (let id in manifestIdToFileNameMap) {
@@ -1104,13 +1163,13 @@ function createCombinedManfest(omniaServiceId, manifestIds, targetManifestId, ta
1104
1163
  throw Error("Couldn't extract manifest id from filename: " + currentFilename);
1105
1164
  }
1106
1165
  let content = fsExtra.readFileSync(filePath, 'utf8');
1107
- mergedContent = `
1108
- ${mergedContent}
1166
+ mergedJsContent = `
1167
+ ${mergedJsContent}
1109
1168
  /* Start of resource:${manifestId} */omniaWebpackJsonp["bb000000-0000-bbbb-0000-0000000000bb"]["${fx_models_1.OmniaResourceManifests.FxCore.toString()}"]("06e712d2-9897-4891-9353-148547efe61c").ManifestResourceLoader.registerWebComponentFromGroupBundle("${omniaServiceId}", "${manifestId}", "${targetManifestId}", function(){
1110
1169
  ${content}
1111
1170
  })//End of resource:${manifestId} `;
1112
1171
  });
1113
- fsExtra.writeFileSync(`${outputDir}/${targetFileName}`, `/******/ if (typeof omniaLoader === 'undefined') {
1172
+ fsExtra.writeFileSync(`${outputDir}/${targetJsFileName}`, `/******/ if (typeof omniaLoader === 'undefined') {
1114
1173
  /******/ globalThis['omniaLoader'] = {};
1115
1174
  /******/ }
1116
1175
  /******/ omniaLoader['${omniaServiceId}'] = omniaLoader['${omniaServiceId}'] || {};
@@ -1119,7 +1178,7 @@ ${content}
1119
1178
  /******/
1120
1179
  }
1121
1180
  /******/ omniaLoader['${omniaServiceId}']['${targetManifestId}'] = function () {
1122
- ${mergedContent}
1181
+ ${mergedJsContent}
1123
1182
  }
1124
1183
  ${$.composers.LoadableManifestRegistry.isDefineWithNoDependency(targetManifestId) ? `omniaLoader['${omniaServiceId}']['${targetManifestId}']()` : ''}`, 'utf8');
1125
1184
  $.tooling.log("Done - Creating manifest group bundle for manifest id: " + targetManifestId, $.tooling.LogTypes.HeadLine);
@@ -1203,12 +1262,17 @@ function buildReferenceManifest(currentEntry, entries) {
1203
1262
  var manifests = [];
1204
1263
  var dynamicReferenceManifests = [];
1205
1264
  let buildOptions = getBuildOption();
1206
- if (buildOptions && buildOptions.bundleOptions && buildOptions.bundleOptions.commonsChunk)
1207
- return dynamicReferenceManifests.concat(buildReferenceManifestFromConfig());
1208
1265
  var currentEntryName = Object.keys(currentEntry)[0];
1209
- // exclude omnia vendor
1210
- if (currentEntryName.indexOf(fx_models_1.OmniaResourceManifests.Vendor.toString()) === -1
1211
- && currentEntryName.indexOf(vendorProdId) === -1) {
1266
+ if (buildOptions && buildOptions.bundleOptions && buildOptions.bundleOptions.commonsChunk)
1267
+ return dynamicReferenceManifests.concat(buildReferenceManifestFromConfig(currentEntryName));
1268
+ // exclude pre-built webpack manifest
1269
+ if ($.isExtensionEnv
1270
+ || (currentEntryName.indexOf(fx_models_1.OmniaResourceManifests.Vendor.toString()) === -1
1271
+ && currentEntryName.indexOf(vendorProdId) === -1
1272
+ // && currentEntryName.indexOf(OmniaResourceManifests.FxCore.toString()) === -1
1273
+ // && currentEntryName.indexOf(OmniaResourceManifests.Fx.toString()) === -1
1274
+ // && currentEntryName.indexOf(OmniaResourceManifests.FxUx.toString()) === -1
1275
+ )) {
1212
1276
  Object.keys(entries).forEach((entryName) => {
1213
1277
  if (entryName !== currentEntryName) {
1214
1278
  if ($.fs.existsSync($.tooling.utils.root(outDirManifestMetadata + "/" + entryName + ".manifest.json"))) {
@@ -1222,14 +1286,14 @@ function buildReferenceManifest(currentEntry, entries) {
1222
1286
  }
1223
1287
  });
1224
1288
  }
1225
- manifests = buildReferenceManifestFromConfig().concat(dynamicReferenceManifests).concat(manifests);
1289
+ manifests = buildReferenceManifestFromConfig(currentEntryName).concat(dynamicReferenceManifests).concat(manifests);
1226
1290
  return manifests;
1227
1291
  }
1228
1292
  function cleanUpComposer() {
1229
1293
  $.composers.ManifestRegistry.clearState();
1230
1294
  }
1231
1295
  exports.cleanUpComposer = cleanUpComposer;
1232
- function buildReferenceManifestFromConfig() {
1296
+ function buildReferenceManifestFromConfig(entryName) {
1233
1297
  var manifests = [];
1234
1298
  let buildOptions = getBuildOption();
1235
1299
  if (buildOptions.reference) {
@@ -1241,6 +1305,17 @@ function buildReferenceManifestFromConfig() {
1241
1305
  }));
1242
1306
  }
1243
1307
  }
1308
+ if (!isBuildWebpackManifestOnly() && buildOptions.webpackManifests) {
1309
+ for (let manifestPath of buildOptions.webpackManifests) {
1310
+ if (manifestPath.indexOf(entryName) === -1) {
1311
+ manifests.push(new $.omniaWebpackPlugins.DllReferencePlugin({
1312
+ context: $.tooling.utils.root(""),
1313
+ manifest: $.tooling.utils.root(manifestPath),
1314
+ // name: `md${++trackingModuleRefId}` //require('md5')(manifestPath)
1315
+ }));
1316
+ }
1317
+ }
1318
+ }
1244
1319
  if ($.isExtensionEnv) {
1245
1320
  _registeredReferenceManifests.forEach(manifest => {
1246
1321
  manifests.push(new $.omniaWebpackPlugins.DllReferencePlugin({
@@ -7,162 +7,23 @@ const path_1 = tslib_1.__importDefault(require("path"));
7
7
  const shared_1 = require("../shared");
8
8
  const tooling_composers_1 = require("@omnia/tooling-composers");
9
9
  const tooling_1 = require("@omnia/tooling");
10
- const core_1 = require("@swc/core");
11
10
  const fsExtra = tslib_1.__importStar(require("fs-extra"));
12
11
  const fx_models_1 = require("@omnia/fx-models");
13
12
  async function generateComponentTypingsAndDoc(componentRegistrations) {
14
13
  tooling_1.utils.log("Generate components typings and documentation running...");
15
14
  var startTime = new Date().getTime();
16
- let DefineVueType;
17
- (function (DefineVueType) {
18
- DefineVueType[DefineVueType["Prop"] = 0] = "Prop";
19
- DefineVueType[DefineVueType["Model"] = 1] = "Model";
20
- DefineVueType[DefineVueType["Slot"] = 2] = "Slot";
21
- DefineVueType[DefineVueType["Emit"] = 4] = "Emit";
22
- })(DefineVueType || (DefineVueType = {}));
23
15
  const docResult = {};
24
- function getPropertyFunctionTypeAsString(type) {
25
- let params = "";
26
- if (type.params?.length > 0) {
27
- type.params.forEach(p => {
28
- params += `${p.value}:${getPropertyType(p.typeAnnotation)}, `;
29
- });
30
- params = params.replace(/,\s*$/, "");
31
- }
32
- return `(${params}) => ${getPropertyType(type.typeAnnotation)}`;
33
- }
34
- function getPropertyType(tsType) {
35
- let result = "";
36
- if (tsType.type === "TsTypeAnnotation") {
37
- return getPropertyType(tsType.typeAnnotation);
38
- }
39
- switch (tsType.type) {
40
- case "TsLiteralType":
41
- result = tsType.literal.value;
42
- break;
43
- case "TsKeywordType":
44
- result = tsType.kind;
45
- break;
46
- case "TsTypeReference":
47
- result = tsType.typeName.value;
48
- break;
49
- case "TsFunctionType":
50
- result = getPropertyFunctionTypeAsString(tsType);
51
- break;
52
- default:
53
- break;
54
- }
55
- return result;
56
- }
57
- function getNameProperty(ce, result) {
58
- const identifier = ce.callee?.property?.value;
59
- if (identifier) {
60
- switch (identifier) {
61
- case "name":
62
- result.name = ce.arguments[0].expression.value;
63
- getNameProperty(ce.callee.object, result);
64
- break;
65
- case "vModel":
66
- result.type = DefineVueType.Model;
67
- result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
68
- result.name = result.name ? `v-model:${result.name}` : result.name;
69
- break;
70
- case "slots":
71
- result.type = DefineVueType.Slot;
72
- result.propertyTypeAsObject = {};
73
- ce.typeArguments.params[0].members
74
- .forEach(m => {
75
- result.propertyTypeAsObject[m.key.value] = getPropertyType(m.typeAnnotation);
76
- });
77
- break;
78
- case "prop":
79
- result.type = DefineVueType.Prop;
80
- result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
81
- break;
82
- case "emit":
83
- result.type = DefineVueType.Emit;
84
- result.propertyTypeAsString = getPropertyType(ce.typeArguments.params[0]);
85
- break;
86
- default:
87
- getNameProperty(ce.callee.object, result);
88
- }
89
- }
90
- }
91
16
  async function buildDoc(wc) {
92
17
  try {
93
18
  const wcPath = (0, shared_1.convertManifestPathToEntryPath)(wc.manifestPath, [wc.componentOptions.entryPoint])[0];
94
- const wcParseResult = await (0, core_1.parseFile)(wcPath, {
95
- syntax: 'typescript',
96
- target: 'es2020',
97
- tsx: true,
98
- decorators: true,
99
- dynamicImport: true
100
- });
101
- wcParseResult.body.forEach(b => {
102
- if (b.type === 'ExportDefaultExpression'
103
- && b.expression.callee?.value === "defineVueComponent") {
104
- b.expression.arguments[0].expression
105
- .properties?.filter(p => p.key.value === "props"
106
- || p.key.value === "emits")
107
- ?.forEach(propsIdentifier => {
108
- if (propsIdentifier) {
109
- propsIdentifier.value
110
- .properties?.forEach(p => {
111
- const em = p.arguments;
112
- if (em?.callee?.property?.value === "doc$") {
113
- const PropertyResult = {
114
- type: null,
115
- propertyTypeAsString: "",
116
- name: ""
117
- };
118
- getNameProperty(em, PropertyResult);
119
- if (!docResult[wc.componentOptions.elementName]) {
120
- docResult[wc.componentOptions.elementName] = {
121
- emits: {},
122
- models: {},
123
- props: {},
124
- slots: {}
125
- };
126
- }
127
- switch (PropertyResult.type) {
128
- case DefineVueType.Prop:
129
- docResult[wc.componentOptions.elementName].props[PropertyResult.name] = {
130
- type: PropertyResult.propertyTypeAsString,
131
- description: em.arguments[0].expression.value
132
- };
133
- break;
134
- case DefineVueType.Model:
135
- docResult[wc.componentOptions.elementName].models[PropertyResult.name] = {
136
- type: PropertyResult.propertyTypeAsString,
137
- description: em.arguments[0].expression.value
138
- };
139
- break;
140
- case DefineVueType.Emit:
141
- docResult[wc.componentOptions.elementName].emits[PropertyResult.name] = {
142
- type: PropertyResult.propertyTypeAsString,
143
- description: em.arguments[0].expression.value
144
- };
145
- break;
146
- case DefineVueType.Slot:
147
- em.arguments[0].expression
148
- .properties
149
- .forEach(p => {
150
- const slotName = p.key.value;
151
- docResult[wc.componentOptions.elementName].slots[slotName] = {
152
- type: PropertyResult.propertyTypeAsObject[slotName],
153
- description: p.value.value
154
- };
155
- });
156
- break;
157
- default:
158
- break;
159
- }
160
- }
161
- });
162
- }
163
- });
164
- }
165
- });
19
+ const elementName = wc.componentOptions.elementName;
20
+ const result = (0, shared_1.extractVueComponentInfo)(wcPath);
21
+ docResult[elementName] = {
22
+ emits: result.emits,
23
+ models: result.models,
24
+ props: result.props,
25
+ slots: result.slots
26
+ };
166
27
  }
167
28
  catch (ex) {
168
29
  tooling_1.utils.log(`Have a exception when extract doc$ for web component manifest -> ${wc.manifestPath}`, tooling_1.utils.LogTypes.Error);
@@ -171,35 +32,18 @@ async function generateComponentTypingsAndDoc(componentRegistrations) {
171
32
  }
172
33
  }
173
34
  let docPath = path_1.default.resolve(__dirname, "ComponentDocRegistrations.ts");
174
- ;
175
- const wcNamespace = (0, shared_1.getBuildOption)()?.webComponentNamespace;
176
- const info = shared_1.ConfigurationManager.outputInfo.get();
177
- info.wc = {
178
- namespace: wcNamespace,
179
- mappings: {}
180
- };
181
- let wcTypings = wcNamespace ? `
35
+ let wcTypings = `
182
36
  //{{importWC}}
183
- declare global {
184
- namespace JSX {
185
- interface Element { }
186
- interface ElementClass { }
187
37
 
188
- interface IntrinsicElements {
189
- //{{elementName}}
190
- }
38
+ type ExtractJsxProps<T> = {
39
+ [K in keyof (T extends { propsDefinition: any } ? T["propsDefinition"] : T)]: T extends {
40
+ propsDefinition: any;
191
41
  }
192
- }
42
+ ? T["propsDefinition"][K]
43
+ : never;
44
+ } & { $children?: any; };
193
45
 
194
46
  declare global {
195
- let ${wcNamespace}: {
196
- //{{nselementName}}
197
- };
198
- }
199
- `
200
- : `
201
- //{{importWC}}
202
- declare global {
203
47
  namespace JSX {
204
48
  interface Element { }
205
49
  interface ElementClass { }
@@ -217,10 +61,34 @@ declare global {
217
61
  wcTypings = `import { VueComponentBaseProps } from "../../../../client/fx/ux/index";
218
62
  ${wcTypings}`;
219
63
  }
64
+ const elementNamespaces = {};
65
+ const wcNamespace = (0, shared_1.getBuildOption)()?.componentNamespace;
66
+ const info = shared_1.ConfigurationManager.outputInfo.get();
67
+ info.wc = {
68
+ namespaces: wcNamespace ? [wcNamespace] : null,
69
+ mappings: {}
70
+ };
220
71
  await tooling_1.utils.asyncForEach(componentRegistrations, async (wc) => {
221
- wcTypings = generateWebComponentTypings(wc, wcTypings, info);
222
- await buildDoc(wc);
72
+ wcTypings = generateWebComponentTypings(wc, wcTypings, info, elementNamespaces);
73
+ if ((0, shared_1.getBuildOption)().docResourceManifestId) {
74
+ await buildDoc(wc);
75
+ }
223
76
  });
77
+ if (Object.keys(elementNamespaces).length > 0) {
78
+ let result = `declare global {
79
+ //{{namespace}}
80
+ }`;
81
+ Object.keys(elementNamespaces).forEach(key => {
82
+ result = result.replace("//{{namespace}}", `
83
+ let ${key}: ${JSON.stringify(elementNamespaces[key], null, 2)
84
+ .replace(/\"typeof /g, "typeof ").replace(/ <<end>>\"/g, "")}
85
+ //{{namespace}}
86
+ `);
87
+ });
88
+ wcTypings = wcTypings + `
89
+ ${result}
90
+ `;
91
+ }
224
92
  if (Object.keys(docResult).length > 0) {
225
93
  fsExtra.outputFileSync(docPath, `
226
94
  import { extendApi } from "@omnia/fx";
@@ -242,7 +110,7 @@ extendApi(api => api.fx.docs.registrations, api => {
242
110
  .registerResources({
243
111
  resourcePaths: ["./ComponentDocRegistrations.ts"]
244
112
  })
245
- .withTarget(fx_models_1.ClientManifestTargetTypes.Docs)
113
+ .withTarget(fx_models_1.ClientManifestTargetTypes.docs)
246
114
  .extendApi(api => api.fx.docs.registrations);
247
115
  tooling_composers_1.ManifestRegistry.setCurrentManifestPath();
248
116
  }
@@ -251,7 +119,7 @@ extendApi(api => api.fx.docs.registrations, api => {
251
119
  tooling_1.utils.logTime('Done - Generate components typings and documentation', startTime);
252
120
  }
253
121
  exports.generateComponentTypingsAndDoc = generateComponentTypingsAndDoc;
254
- function generateWebComponentTypings(wc, template, info) {
122
+ function generateWebComponentTypings(wc, template, info, elementNamespace) {
255
123
  // export default defineVueWebComponent
256
124
  const wcPath = wc.componentOptions.entryPointPath;
257
125
  let content = fsExtra.readFileSync(wcPath, 'utf8');
@@ -270,16 +138,32 @@ function generateWebComponentTypings(wc, template, info) {
270
138
  else {
271
139
  importPath = `../../../../${importPath}`;
272
140
  }
273
- let elementNamePascalCase = wc.componentOptions.elementName.replace("omfx-", "").replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
274
- elementNamePascalCase = elementNamePascalCase[0].toUpperCase() + elementNamePascalCase.substring(1, elementNamePascalCase.length);
275
- info.wc.mappings[elementNamePascalCase] = wc.componentOptions.elementName;
141
+ if (info.wc.namespaces) {
142
+ let elementName = wc.componentOptions.elementName.replace(/-/g, ".");
143
+ const namespace = (wc.componentOptions.namespace === true ? "" : wc.componentOptions.namespace) || (0, shared_1.getBuildOption)()?.componentNamespace;
144
+ if (namespace && elementName.indexOf(`${namespace}.`) !== 0) {
145
+ elementName = `${namespace}.${elementName}`;
146
+ }
147
+ if (info.wc.namespaces && info.wc.namespaces.indexOf(elementName.split(".")[0]) === -1) {
148
+ info.wc.namespaces.push(elementName.split(".")[0]);
149
+ }
150
+ info.wc.mappings[elementName] = wc.componentOptions.elementName;
151
+ try {
152
+ populateElementNamespace(elementNamespace, elementName, friendlyManifestId);
153
+ }
154
+ catch (ex) {
155
+ tooling_1.utils.log(`Have a exception in building element namespace with element name: ${wc.componentOptions.elementName}`, tooling_1.utils.LogTypes.Error);
156
+ console.error(ex);
157
+ throw new Error("Exit, have an exception.");
158
+ }
159
+ }
276
160
  return template
277
161
  .replace(/\/\/{{importWC}}/, `import ${friendlyManifestId} from '${importPath}';
278
162
  //{{importWC}}`)
279
- .replace(/\/\/{{elementName}}/, `"${wc.componentOptions.elementName}": typeof ${friendlyManifestId}.propsDefinition & Omit<VueComponentBaseProps, keyof typeof ${friendlyManifestId}.propsDefinition>
280
- //{{elementName}}`)
281
- .replace(/\/\/{{nselementName}}/, `"${elementNamePascalCase}": { new(...args: any[]): { $props: typeof ${friendlyManifestId}.propsDefinition & Omit<VueComponentBaseProps, keyof typeof ${friendlyManifestId}.propsDefinition> } }
282
- //{{nselementName}}`);
163
+ .replace(/\/\/{{elementName}}/, `"${wc.componentOptions.elementName}": typeof ${friendlyManifestId} extends { propsDefinition: infer TProp } ? (TProp & Omit<VueComponentBaseProps, keyof TProp>) : typeof ${friendlyManifestId} extends (...args: any[]) => any ? ExtractJsxProps<Pick<ReturnType<typeof ${friendlyManifestId}>, "propsDefinition">> : never
164
+ //{{elementName}}`);
165
+ // .replace(/\/\/{{nselementName}}/, `"${elementName}": { new(...args: any[]): { $props: typeof ${friendlyManifestId}.propsDefinition & Omit<VueComponentBaseProps, keyof typeof ${friendlyManifestId}.propsDefinition> } }
166
+ // //{{nselementName}}`)
283
167
  }
284
168
  return template;
285
169
  }
@@ -309,3 +193,34 @@ function importSnippetCode(content, filePath) {
309
193
  return result;
310
194
  }
311
195
  exports.importSnippetCode = importSnippetCode;
196
+ function populateElementNamespace(namespace, elementName, importElement) {
197
+ const parts = elementName.split(".");
198
+ for (let i = 0; i < parts.length; i++) {
199
+ const name = parts[i];
200
+ if (typeof namespace === "string") {
201
+ throw new Error("Build element namespace -> that element name contain another element name");
202
+ }
203
+ if (!namespace[name]) {
204
+ if (i === parts.length - 1) {
205
+ namespace[name] = `typeof ${importElement} extends { propsDefinition: infer TProp } ? { new(...args: any[]): { $props: TProp & Omit<VueComponentBaseProps, keyof TProp> } } : typeof ${importElement} <<end>>`;
206
+ }
207
+ else {
208
+ namespace = namespace[name] = {};
209
+ }
210
+ }
211
+ else {
212
+ if (i === parts.length - 1) {
213
+ namespace[`${name}$`] = `typeof ${importElement} extends { propsDefinition: infer TProp } ? { new(...args: any[]): { $props: TProp & Omit<VueComponentBaseProps, keyof TProp> } } : typeof ${importElement} <<end>>`;
214
+ // throw new Error("Build element namespace -> Exist an element name contain a above that element name");
215
+ }
216
+ else {
217
+ if (typeof namespace[name] === "string") {
218
+ tooling_1.utils.log(`Generate namespace for component with suffix $ -> ${parts.slice(0, i + 1).join(".")}$`);
219
+ namespace[`${name}$`] = namespace[name];
220
+ namespace[name] = {};
221
+ }
222
+ namespace = namespace[name];
223
+ }
224
+ }
225
+ }
226
+ }