@omnia/tooling-vue 8.0.107-vnext → 8.0.108-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 (34) 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 +4465 -1547
  8. package/internal-do-not-import-from-here/shared.d.ts +32 -10
  9. package/internal-do-not-import-from-here/shared.js +308 -27
  10. package/internal-do-not-import-from-here/tasks/ComponentDocRegistrations.js +1 -1
  11. package/internal-do-not-import-from-here/tasks/bundle.js +92 -32
  12. package/internal-do-not-import-from-here/tasks/doc.d.ts +1 -0
  13. package/internal-do-not-import-from-here/tasks/doc.js +125 -183
  14. package/internal-do-not-import-from-here/tasks/vendor.js +22 -16
  15. package/internal-do-not-import-from-here/vite/hmr/graph.js +3 -1
  16. package/internal-do-not-import-from-here/vite/hmr/vueJsx.js +3 -2
  17. package/internal-do-not-import-from-here/vite/index.js +1 -1
  18. package/internal-do-not-import-from-here/vite/plugins/OmniaPlugin.js +1 -1
  19. package/internal-do-not-import-from-here/webpack-loaders/doc-loader.d.ts +1 -0
  20. package/internal-do-not-import-from-here/webpack-loaders/doc-loader.js +11 -0
  21. package/internal-do-not-import-from-here/webpack-loaders/esbuild-custom-loader.d.ts +1 -0
  22. package/internal-do-not-import-from-here/webpack-loaders/esbuild-custom-loader.js +10 -0
  23. package/internal-do-not-import-from-here/webpack-loaders/ts-loader.d.ts +5 -2
  24. package/internal-do-not-import-from-here/webpack-loaders/ts-loader.js +8 -0
  25. package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.d.ts +3 -3
  26. package/internal-do-not-import-from-here/webpack-loaders/tsx-loader.js +9 -3
  27. package/internal-do-not-import-from-here/webpack-loaders/vue-component-loader.d.ts +1 -0
  28. package/internal-do-not-import-from-here/webpack-loaders/{wc-loader.js → vue-component-loader.js} +3 -1
  29. package/internal-do-not-import-from-here/webpack-plugins/stylexjs/index.d.ts +53 -0
  30. package/internal-do-not-import-from-here/webpack-plugins/stylexjs/index.js +194 -0
  31. package/internal-do-not-import-from-here/webpack-plugins/stylexjs/loader.d.ts +9 -0
  32. package/internal-do-not-import-from-here/webpack-plugins/stylexjs/loader.js +23 -0
  33. package/package.json +10 -10
  34. package/internal-do-not-import-from-here/webpack-loaders/wc-loader.d.ts +0 -1
@@ -4,36 +4,58 @@ export interface WebComponentOptionsExtends extends WebComponentOptions {
4
4
  }
5
5
  export type OutputInfo = {
6
6
  wc: {
7
- namespace: string;
7
+ namespaces: string[];
8
8
  mappings: {
9
9
  [element: string]: string;
10
10
  };
11
11
  };
12
12
  };
13
+ type ComponentPropInfo = {
14
+ type: string;
15
+ description?: string;
16
+ required?: boolean;
17
+ defaultValue?: any;
18
+ };
19
+ type ComponentInfo = {
20
+ functionSignature?: boolean;
21
+ props: {
22
+ [name: string]: ComponentPropInfo;
23
+ };
24
+ models: {
25
+ [name: string]: ComponentPropInfo;
26
+ };
27
+ slots: {
28
+ [name: string]: ComponentPropInfo;
29
+ };
30
+ emits: {
31
+ [name: string]: ComponentPropInfo;
32
+ };
33
+ };
13
34
  export declare const isExtensionEnv: boolean;
14
- export declare function getBuildOption(): import("@omnia/tooling-composers").BuildOptions;
15
- export declare function registerOutputInfo(info: OutputInfo): void;
16
- export declare function modifyComponent(content: string, filePath: string): string;
17
- export declare function convertManifestPathToEntryPath(pathToManifest: any, pathsInManifest: Array<string>): string[];
18
35
  export declare const buildContext: {
19
36
  isManifestsChanged: boolean;
20
37
  };
21
- export declare var cacheKeys: {
38
+ export declare const cacheKeys: {
22
39
  bundleManifests: string;
23
40
  };
41
+ export declare function getBuildOption(): import("@omnia/tooling-composers").BuildOptions;
42
+ export declare function registerOutputInfo(info: OutputInfo): void;
43
+ export declare function transformDefineVueComponent(content: string, filePath: string): string;
44
+ export declare function extractVueComponentInfo(filePath: string): ComponentInfo;
45
+ export declare function convertManifestPathToEntryPath(pathToManifest: any, pathsInManifest: Array<string>): string[];
24
46
  export declare class ConfigurationManager {
25
47
  private static _webComponentTypings;
26
48
  private static _outputInfoManagaer;
27
- static get webComponentTypings(): WebComponentTypingsManagaer;
28
- static get outputInfo(): OutputInfoManagaer;
49
+ static get webComponentTypings(): ImplementComponentTyping;
50
+ static get outputInfo(): OutputInfoManager;
29
51
  }
30
- declare class OutputInfoManagaer {
52
+ declare class OutputInfoManager {
31
53
  private filePath;
32
54
  private _value;
33
55
  update(value: OutputInfo): void;
34
56
  get(): OutputInfo;
35
57
  }
36
- declare class WebComponentTypingsManagaer {
58
+ declare class ImplementComponentTyping {
37
59
  private filePath;
38
60
  update(value: string): void;
39
61
  delete(): void;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigurationManager = exports.cacheKeys = exports.buildContext = exports.convertManifestPathToEntryPath = exports.modifyComponent = exports.registerOutputInfo = exports.getBuildOption = exports.isExtensionEnv = void 0;
3
+ exports.ConfigurationManager = exports.convertManifestPathToEntryPath = exports.extractVueComponentInfo = exports.transformDefineVueComponent = exports.registerOutputInfo = exports.getBuildOption = exports.cacheKeys = exports.buildContext = exports.isExtensionEnv = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const globby_1 = require("globby");
6
6
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -8,37 +8,325 @@ const fsExtra = tslib_1.__importStar(require("fs-extra"));
8
8
  const del_1 = tslib_1.__importDefault(require("del"));
9
9
  const fs_1 = tslib_1.__importDefault(require("fs"));
10
10
  const tooling_composers_1 = require("@omnia/tooling-composers");
11
- const _outputInfos = [];
11
+ const core_1 = require("@swc/core");
12
+ const tooling_1 = require("@omnia/tooling");
13
+ var DefineVueType;
14
+ (function (DefineVueType) {
15
+ DefineVueType[DefineVueType["Prop"] = 0] = "Prop";
16
+ DefineVueType[DefineVueType["Model"] = 1] = "Model";
17
+ DefineVueType[DefineVueType["Slot"] = 2] = "Slot";
18
+ DefineVueType[DefineVueType["Emit"] = 3] = "Emit";
19
+ })(DefineVueType || (DefineVueType = {}));
20
+ const outputInfos = [];
12
21
  const basePathProcess = process.cwd();
22
+ const componentInfos = {};
13
23
  exports.isExtensionEnv = fs_1.default.existsSync(basePathProcess + "/node_modules/@omnia/tooling/package.json");
24
+ exports.buildContext = {
25
+ isManifestsChanged: false
26
+ };
27
+ exports.cacheKeys = {
28
+ //buildManifestMetadatas: "buildManifestMetadatas",
29
+ bundleManifests: "bundleManifests"
30
+ };
14
31
  function getBuildOption() {
15
32
  return tooling_composers_1.BuildConfigurationRegistry.getBuildOptions();
16
33
  }
17
34
  exports.getBuildOption = getBuildOption;
18
35
  function registerOutputInfo(info) {
19
- _outputInfos.push(info);
36
+ outputInfos.push(info);
20
37
  }
21
38
  exports.registerOutputInfo = registerOutputInfo;
22
- function modifyComponent(content, filePath) {
39
+ function transformDefineVueComponent(content, filePath) {
23
40
  let result = content;
24
- if (path_1.default.extname(filePath) === ".tsx") {
25
- result = replaceWebComponentNamespaceMapping(content);
41
+ const ext = path_1.default.extname(filePath);
42
+ if (ext === ".tsx") {
43
+ result = replaceComponentNamespace(content);
44
+ const componentInfo = extractVueComponentInfo(filePath);
26
45
  const wcs = tooling_composers_1.ComponentRegistry.getComponentRegistrations();
27
46
  if (wcs.find(wc => filePath.indexOf(wc.componentOptions.entryPointPath) > -1)) {
28
- result = result.replace(/defineVueComponent/g, "defineVueWebComponent");
47
+ if (componentInfo.functionSignature) {
48
+ result = result.replace(/defineVueComponent/g, "internalDVWCByFS");
49
+ result = result.replace(/internalDVWCByFS(\s*)\(/g, `internalDVWCByFS(${convertComponentOptionsToString(componentInfo)},`);
50
+ // console.log(result)
51
+ }
52
+ else {
53
+ result = result.replace(/defineVueComponent/g, "defineVueWebComponent");
54
+ }
55
+ }
56
+ else if (componentInfo.functionSignature) {
57
+ result = result.replace(/defineVueComponent/g, "internalDVCByFS");
58
+ result = result.replace(/internalDVCByFS(\s*)\(/g, `internalDVCByFS(${convertComponentOptionsToString(componentInfo)},`);
29
59
  }
30
60
  }
31
61
  return result;
32
62
  }
33
- exports.modifyComponent = modifyComponent;
34
- function replaceWebComponentNamespaceMapping(content) {
35
- const infos = _outputInfos.concat(ConfigurationManager.outputInfo.get());
63
+ exports.transformDefineVueComponent = transformDefineVueComponent;
64
+ function extractVueComponentInfo(filePath) {
65
+ if (!tooling_1.isServing && componentInfos[filePath]) {
66
+ return componentInfos[filePath];
67
+ }
68
+ const componentInfo = {
69
+ emits: {},
70
+ models: {},
71
+ props: {},
72
+ slots: {}
73
+ };
74
+ componentInfos[filePath] = componentInfo;
75
+ const wcParseResult = (0, core_1.parseFileSync)(filePath, {
76
+ syntax: 'typescript',
77
+ target: 'es2020',
78
+ tsx: true,
79
+ decorators: true,
80
+ dynamicImport: true
81
+ });
82
+ let foundDefineVueComponent = false;
83
+ wcParseResult.body.forEach(b => {
84
+ if (b?.expression?.callee?.value === "defineVueComponent") {
85
+ if (foundDefineVueComponent) {
86
+ throw new Error(`${filePath}: have more than once call defineVueComponent -> Only support define once vue component on each .tsx file.`);
87
+ }
88
+ foundDefineVueComponent = true;
89
+ const callExpression = b.expression;
90
+ if (callExpression.arguments[0].expression.type === "ArrowFunctionExpression") {
91
+ componentInfo.functionSignature = true;
92
+ const params = callExpression.arguments[0].expression.params;
93
+ const typeParams = params[0].typeAnnotation.typeAnnotation.typeParams.params;
94
+ const props = typeParams[0];
95
+ const types = props.types ? props.types : [props];
96
+ types.forEach((t) => {
97
+ const typeName = t.typeName.value;
98
+ if (typeName === "DefineProp" || typeName === "DefineVModel") {
99
+ const params = t.typeParams.params;
100
+ const name = extractTypeValue(params[0]) || "modelValue";
101
+ const type = extractTypeValue(params[1]);
102
+ // if(!type)console.log(filePath, name, params[1])
103
+ const required = params.length > 2 ? extractTypeValue(params[2]) : false;
104
+ const defaultValue = params.length > 3 ? extractTypeValue(params[3], true) : undefined;
105
+ const description = params.length > 4 ? extractTypeValue(params[4]) : "";
106
+ const info = {
107
+ type: type,
108
+ description: description,
109
+ required: required.toString().toLowerCase() === "true" ? true : false
110
+ };
111
+ if (defaultValue !== undefined) {
112
+ info.defaultValue = defaultValue;
113
+ }
114
+ if (typeName === "DefineVModel") {
115
+ componentInfo.models[name] = info;
116
+ }
117
+ else { // props
118
+ componentInfo.props[name] = info;
119
+ }
120
+ }
121
+ });
122
+ if (typeParams.length > 1) {
123
+ const emits = typeParams[1];
124
+ const types = emits.types ? emits.types : [emits];
125
+ types.forEach((t) => {
126
+ const typeName = t.typeName.value;
127
+ if (typeName === "DefineEmit") {
128
+ const params = t.typeParams.params;
129
+ const name = extractTypeValue(params[0]);
130
+ const type = extractTypeValue(params[1]);
131
+ const description = params.length > 2 ? extractTypeValue(params[2]) : "";
132
+ componentInfo.emits[name] = {
133
+ type: type,
134
+ description: description,
135
+ };
136
+ }
137
+ });
138
+ }
139
+ if (typeParams.length > 2) {
140
+ const slots = typeParams[2];
141
+ const types = slots.types ? slots.types : [slots];
142
+ types.forEach((t) => {
143
+ const typeName = t.typeName.value;
144
+ if (typeName === "DefineSlot") {
145
+ const params = t.typeParams.params;
146
+ const name = extractTypeValue(params[0]);
147
+ const type = extractTypeValue(params[1]);
148
+ const description = params.length > 2 ? extractTypeValue(params[2]) : "";
149
+ componentInfo.slots[name] = {
150
+ type: type,
151
+ description: description,
152
+ };
153
+ }
154
+ });
155
+ }
156
+ }
157
+ else {
158
+ callExpression.arguments[0].expression
159
+ .properties?.filter(p => p.key.value === "props"
160
+ || p.key.value === "emits")
161
+ ?.forEach(propsIdentifier => {
162
+ if (propsIdentifier) {
163
+ propsIdentifier.value
164
+ .properties?.forEach(p => {
165
+ const em = p.arguments;
166
+ if (em?.callee?.property?.value === "doc$") {
167
+ const PropertyResult = {
168
+ type: null,
169
+ propertyTypeAsString: "",
170
+ name: ""
171
+ };
172
+ getPropertyInfo(em, PropertyResult);
173
+ switch (PropertyResult.type) {
174
+ case DefineVueType.Prop:
175
+ componentInfo.props[PropertyResult.name] = {
176
+ type: PropertyResult.propertyTypeAsString,
177
+ description: em.arguments[0].expression.value
178
+ };
179
+ break;
180
+ case DefineVueType.Model:
181
+ componentInfo.models[PropertyResult.name] = {
182
+ type: PropertyResult.propertyTypeAsString,
183
+ description: em.arguments[0].expression.value
184
+ };
185
+ break;
186
+ case DefineVueType.Emit:
187
+ componentInfo.emits[PropertyResult.name] = {
188
+ type: PropertyResult.propertyTypeAsString,
189
+ description: em.arguments[0].expression.value
190
+ };
191
+ break;
192
+ case DefineVueType.Slot:
193
+ em.arguments[0].expression
194
+ .properties
195
+ .forEach(p => {
196
+ const slotName = p.key.value;
197
+ componentInfo.slots[slotName] = {
198
+ type: PropertyResult.propertyTypeAsObject[slotName],
199
+ description: p.value.value
200
+ };
201
+ });
202
+ break;
203
+ default:
204
+ break;
205
+ }
206
+ }
207
+ });
208
+ }
209
+ });
210
+ }
211
+ }
212
+ });
213
+ return componentInfo;
214
+ }
215
+ exports.extractVueComponentInfo = extractVueComponentInfo;
216
+ function convertComponentOptionsToString(component) {
217
+ function getEmits() {
218
+ let result = "";
219
+ Object.keys(component.emits).forEach(name => {
220
+ result = `${result} "${name}",`;
221
+ });
222
+ return result;
223
+ }
224
+ function getProps() {
225
+ let result = "";
226
+ Object.keys(component.props).forEach(name => {
227
+ result = `${result} ${name}:${component.props[name].defaultValue !== undefined && component.props[name].defaultValue !== "null" ? `{default: ${component.props[name].defaultValue}},` : "{},"}`;
228
+ });
229
+ Object.keys(component.models).forEach(name => {
230
+ result = `${result} ${name}:${component.models[name].defaultValue !== undefined && component.models[name].defaultValue !== "null" ? `{default: ${component.models[name].defaultValue}},` : "{},"}`;
231
+ });
232
+ return result;
233
+ }
234
+ return `{ emits: [${getEmits()}], props: {${getProps()}} }`;
235
+ }
236
+ function extractTypeValue(tsType, rawValue = false) {
237
+ let result = "";
238
+ if (tsType.type === "TsTypeAnnotation") {
239
+ return extractTypeValue(tsType.typeAnnotation);
240
+ }
241
+ if (tsType.type === "TsArrayType") {
242
+ return extractTypeValue(tsType.elemType);
243
+ }
244
+ if (tsType.type === "TsUnionType") {
245
+ const types = [];
246
+ tsType.types.forEach(t => types.push(extractTypeValue(t)));
247
+ return types.join(" | ");
248
+ }
249
+ switch (tsType.type) {
250
+ case "TsLiteralType":
251
+ if (rawValue && tsType.literal.type === "StringLiteral") {
252
+ result = tsType.literal.raw;
253
+ }
254
+ else {
255
+ result = tsType.literal.value;
256
+ }
257
+ break;
258
+ case "TsKeywordType":
259
+ result = tsType.kind;
260
+ break;
261
+ case "TsTypeReference":
262
+ result = tsType.typeName.value;
263
+ break;
264
+ case "TsTypeQuery":
265
+ result = tsType.exprName.value;
266
+ break;
267
+ case "TsFunctionType":
268
+ result = getPropertyFunctionTypeAsString(tsType);
269
+ break;
270
+ default:
271
+ break;
272
+ }
273
+ return result;
274
+ }
275
+ function getPropertyFunctionTypeAsString(type) {
276
+ let params = "";
277
+ if (type.params?.length > 0) {
278
+ type.params.forEach(p => {
279
+ params += `${p.value}:${extractTypeValue(p.typeAnnotation)}, `;
280
+ });
281
+ params = params.replace(/,\s*$/, "");
282
+ }
283
+ return `(${params}) => ${extractTypeValue(type.typeAnnotation)}`;
284
+ }
285
+ function getPropertyInfo(ce, result) {
286
+ const identifier = ce.callee?.property?.value;
287
+ if (identifier) {
288
+ switch (identifier) {
289
+ case "name":
290
+ result.name = ce.arguments[0].expression.value;
291
+ getPropertyInfo(ce.callee.object, result);
292
+ break;
293
+ case "vModel":
294
+ result.type = DefineVueType.Model;
295
+ result.propertyTypeAsString = extractTypeValue(ce.typeArguments.params[0]);
296
+ result.name = result.name ? `v-model:${result.name}` : result.name;
297
+ break;
298
+ case "slots":
299
+ result.type = DefineVueType.Slot;
300
+ result.propertyTypeAsObject = {};
301
+ ce.typeArguments.params[0].members
302
+ .forEach(m => {
303
+ result.propertyTypeAsObject[m.key.value] = extractTypeValue(m.typeAnnotation);
304
+ });
305
+ break;
306
+ case "prop":
307
+ result.type = DefineVueType.Prop;
308
+ result.propertyTypeAsString = extractTypeValue(ce.typeArguments.params[0]);
309
+ break;
310
+ case "emit":
311
+ result.type = DefineVueType.Emit;
312
+ result.propertyTypeAsString = extractTypeValue(ce.typeArguments.params[0]);
313
+ break;
314
+ default:
315
+ getPropertyInfo(ce.callee.object, result);
316
+ }
317
+ }
318
+ }
319
+ function replaceComponentNamespace(content) {
320
+ const infos = outputInfos.concat(ConfigurationManager.outputInfo.get());
36
321
  infos.forEach(info => {
37
- if (info.wc?.namespace) {
38
- content = content.replace(new RegExp(`(<|<\/|\\s)${info.wc.namespace}\\..*?(>|\\s)`, 'g'), function (match) {
39
- return match.replace(new RegExp(`(${info.wc.namespace}.*)(?=(>|\\s))`), function (token) {
40
- return token.replace(/(\S+)/g, function (tag) {
41
- return info.wc.mappings[tag.replace(`${info.wc.namespace}.`, "")] || tag;
322
+ if (info.wc?.namespaces) {
323
+ info.wc.namespaces.forEach(namespace => {
324
+ content = content.replace(new RegExp(`(<|<\/|\\s)${namespace}\\..*?(>|\\s)`, 'g'), function (match) {
325
+ return match.replace(new RegExp(`(${namespace}.*)(?=(>|\\s))`), function (token) {
326
+ return token.replace(/(\S+)/g, function (tag) {
327
+ // console.log("replaceWebComponentNamespaceMapping", tag)
328
+ return info.wc.mappings[tag.replace("$", "")] || tag;
329
+ });
42
330
  });
43
331
  });
44
332
  });
@@ -61,31 +349,24 @@ function convertManifestPathToEntryPath(pathToManifest, pathsInManifest) {
61
349
  return result;
62
350
  }
63
351
  exports.convertManifestPathToEntryPath = convertManifestPathToEntryPath;
64
- exports.buildContext = {
65
- isManifestsChanged: false
66
- };
67
- exports.cacheKeys = {
68
- //buildManifestMetadatas: "buildManifestMetadatas",
69
- bundleManifests: "bundleManifests"
70
- };
71
352
  class ConfigurationManager {
72
353
  static get webComponentTypings() {
73
354
  if (!this._webComponentTypings) {
74
- this._webComponentTypings = new WebComponentTypingsManagaer();
355
+ this._webComponentTypings = new ImplementComponentTyping();
75
356
  }
76
357
  return this._webComponentTypings;
77
358
  }
78
359
  static get outputInfo() {
79
360
  if (!this._outputInfoManagaer) {
80
- this._outputInfoManagaer = new OutputInfoManagaer();
361
+ this._outputInfoManagaer = new OutputInfoManager();
81
362
  }
82
363
  return this._outputInfoManagaer;
83
364
  }
84
365
  }
366
+ exports.ConfigurationManager = ConfigurationManager;
85
367
  ConfigurationManager._webComponentTypings = null;
86
368
  ConfigurationManager._outputInfoManagaer = null;
87
- exports.ConfigurationManager = ConfigurationManager;
88
- class OutputInfoManagaer {
369
+ class OutputInfoManager {
89
370
  constructor() {
90
371
  this.filePath = exports.isExtensionEnv ? path_1.default.resolve(__dirname, "tooling.output.json") : path_1.default.resolve(__dirname, "config/tooling.output.json");
91
372
  this._value = null;
@@ -103,7 +384,7 @@ class OutputInfoManagaer {
103
384
  return this._value;
104
385
  }
105
386
  }
106
- class WebComponentTypingsManagaer {
387
+ class ImplementComponentTyping {
107
388
  constructor() {
108
389
  this.filePath = exports.isExtensionEnv ? path_1.default.resolve(__dirname, "wctypings.ts") : path_1.default.resolve(__dirname, "config/wctypings.ts");
109
390
  }