@omnia/tooling-vue 8.0.115-vnext → 8.0.117-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 +4561 -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
@@ -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,38 +8,332 @@ 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
41
  const ext = path_1.default.extname(filePath);
25
42
  if (ext === ".tsx") {
26
- result = replaceWebComponentNamespaceMapping(content);
43
+ result = replaceComponentNamespace(content);
44
+ const componentInfo = extractVueComponentInfo(filePath);
27
45
  const wcs = tooling_composers_1.ComponentRegistry.getComponentRegistrations();
28
46
  if (wcs.find(wc => filePath.indexOf(wc.componentOptions.entryPointPath) > -1)) {
29
- 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)},`);
30
59
  }
31
60
  }
32
61
  return result;
33
62
  }
34
- exports.modifyComponent = modifyComponent;
35
- function replaceWebComponentNamespaceMapping(content) {
36
- 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?.length > 0 ? params[0].typeAnnotation.typeAnnotation?.typeParams?.params : null;
94
+ if (typeParams?.length > 0) {
95
+ const props = typeParams[0];
96
+ const types = props.types ? props.types : [props];
97
+ types.filter(t => t.type === "TsTypeReference").forEach((t) => {
98
+ const typeName = t.typeName.value;
99
+ if (typeName === "DefineProp" || typeName === "DefineVModel") {
100
+ const params = t.typeParams.params;
101
+ const name = extractTypeValue(params[0]) || "modelValue";
102
+ const type = extractTypeValue(params[1]);
103
+ // if(!type)console.log(filePath, name, params[1])
104
+ const required = params.length > 2 ? extractTypeValue(params[2]) : false;
105
+ const defaultValue = params.length > 3 ? extractTypeValue(params[3], true) : undefined;
106
+ const description = params.length > 4 ? extractTypeValue(params[4]) : "";
107
+ const info = {
108
+ type: type,
109
+ description: description,
110
+ required: required.toString().toLowerCase() === "true" ? true : false
111
+ };
112
+ if (defaultValue !== undefined && defaultValue !== "null") {
113
+ info.defaultValue = defaultValue;
114
+ }
115
+ if (typeName === "DefineVModel") {
116
+ componentInfo.models[name] = info;
117
+ }
118
+ else { // props
119
+ componentInfo.props[name] = info;
120
+ }
121
+ }
122
+ });
123
+ if (typeParams.length > 1) {
124
+ const emits = typeParams[1];
125
+ const types = emits.types ? emits.types : [emits];
126
+ types.filter(t => t.type === "TsTypeReference").forEach((t) => {
127
+ const typeName = t.typeName.value;
128
+ if (typeName === "DefineEmit") {
129
+ const params = t.typeParams.params;
130
+ const name = extractTypeValue(params[0]);
131
+ const type = extractTypeValue(params[1]);
132
+ const description = params.length > 2 ? extractTypeValue(params[2]) : "";
133
+ componentInfo.emits[name] = {
134
+ type: type,
135
+ description: description,
136
+ };
137
+ }
138
+ });
139
+ }
140
+ if (typeParams.length > 2) {
141
+ const slots = typeParams[2];
142
+ const types = slots.types ? slots.types : [slots];
143
+ types.filter(t => t.type === "TsTypeReference").forEach((t) => {
144
+ const typeName = t.typeName.value;
145
+ if (typeName === "DefineSlot") {
146
+ const params = t.typeParams.params;
147
+ const name = extractTypeValue(params[0]);
148
+ const type = extractTypeValue(params[1]);
149
+ const description = params.length > 2 ? extractTypeValue(params[2]) : "";
150
+ componentInfo.slots[name] = {
151
+ type: type,
152
+ description: description,
153
+ };
154
+ }
155
+ });
156
+ }
157
+ }
158
+ }
159
+ else {
160
+ callExpression.arguments[0].expression
161
+ .properties?.filter(p => p.key.value === "props"
162
+ || p.key.value === "emits")
163
+ ?.forEach(propsIdentifier => {
164
+ if (propsIdentifier) {
165
+ propsIdentifier.value
166
+ .properties?.forEach(p => {
167
+ const em = p.arguments;
168
+ if (em?.callee?.property?.value === "doc$") {
169
+ const PropertyResult = {
170
+ type: null,
171
+ propertyTypeAsString: "",
172
+ name: ""
173
+ };
174
+ getPropertyInfo(em, PropertyResult);
175
+ switch (PropertyResult.type) {
176
+ case DefineVueType.Prop:
177
+ componentInfo.props[PropertyResult.name] = {
178
+ type: PropertyResult.propertyTypeAsString,
179
+ description: em.arguments[0].expression.value
180
+ };
181
+ break;
182
+ case DefineVueType.Model:
183
+ componentInfo.models[PropertyResult.name] = {
184
+ type: PropertyResult.propertyTypeAsString,
185
+ description: em.arguments[0].expression.value
186
+ };
187
+ break;
188
+ case DefineVueType.Emit:
189
+ componentInfo.emits[PropertyResult.name] = {
190
+ type: PropertyResult.propertyTypeAsString,
191
+ description: em.arguments[0].expression.value
192
+ };
193
+ break;
194
+ case DefineVueType.Slot:
195
+ em.arguments[0].expression
196
+ .properties
197
+ .forEach(p => {
198
+ const slotName = p.key.value;
199
+ componentInfo.slots[slotName] = {
200
+ type: PropertyResult.propertyTypeAsObject[slotName],
201
+ description: p.value.value
202
+ };
203
+ });
204
+ break;
205
+ default:
206
+ break;
207
+ }
208
+ }
209
+ });
210
+ }
211
+ });
212
+ }
213
+ }
214
+ });
215
+ return componentInfo;
216
+ }
217
+ exports.extractVueComponentInfo = extractVueComponentInfo;
218
+ function convertComponentOptionsToString(component) {
219
+ function getEmits() {
220
+ let result = "";
221
+ Object.keys(component.emits).forEach(name => {
222
+ result = `${result} "${name}",`;
223
+ });
224
+ return result;
225
+ }
226
+ function getProps() {
227
+ let result = "";
228
+ Object.keys(component.props).forEach(name => {
229
+ result = `${result} ${name}:${component.props[name].defaultValue !== undefined && component.props[name].defaultValue !== "null" ? `{default: ${component.props[name].defaultValue}},` : "{},"}`;
230
+ });
231
+ Object.keys(component.models).forEach(name => {
232
+ result = `${result} ${name}:${component.models[name].defaultValue !== undefined && component.models[name].defaultValue !== "null" ? `{default: ${component.models[name].defaultValue}},` : "{},"}`;
233
+ });
234
+ return result;
235
+ }
236
+ return `{ emits: [${getEmits()}], props: {${getProps()}} }`;
237
+ }
238
+ function extractTypeValue(tsType, rawValue = false) {
239
+ let result = "";
240
+ if (tsType.type === "TsTypeAnnotation") {
241
+ return extractTypeValue(tsType.typeAnnotation);
242
+ }
243
+ if (tsType.type === "TsArrayType") {
244
+ return `${extractTypeValue(tsType.elemType)}[]`;
245
+ }
246
+ if (tsType.type === "TsUnionType") {
247
+ const types = [];
248
+ tsType.types.forEach(t => types.push(extractTypeValue(t)));
249
+ return types.join(" | ");
250
+ }
251
+ switch (tsType.type) {
252
+ case "TsLiteralType":
253
+ if (rawValue && tsType.literal.type === "StringLiteral") {
254
+ result = tsType.literal.raw;
255
+ }
256
+ else {
257
+ result = tsType.literal.value;
258
+ }
259
+ break;
260
+ case "TsKeywordType":
261
+ result = tsType.kind;
262
+ break;
263
+ case "TsTypeReference":
264
+ result = tsType.typeName.value;
265
+ if (tsType.typeParams) {
266
+ const params = [];
267
+ tsType.typeParams.params.forEach(t => params.push(extractTypeValue(t)));
268
+ result = `${result}<${params.join(",")}>`;
269
+ }
270
+ break;
271
+ case "TsTypeQuery":
272
+ result = tsType.exprName.value;
273
+ break;
274
+ case "TsFunctionType":
275
+ result = getPropertyFunctionTypeAsString(tsType);
276
+ break;
277
+ default:
278
+ break;
279
+ }
280
+ return result;
281
+ }
282
+ function getPropertyFunctionTypeAsString(type) {
283
+ let params = "";
284
+ if (type.params?.length > 0) {
285
+ type.params.forEach(p => {
286
+ params += `${p.value}:${extractTypeValue(p.typeAnnotation)}, `;
287
+ });
288
+ params = params.replace(/,\s*$/, "");
289
+ }
290
+ return `(${params}) => ${extractTypeValue(type.typeAnnotation)}`;
291
+ }
292
+ function getPropertyInfo(ce, result) {
293
+ const identifier = ce.callee?.property?.value;
294
+ if (identifier) {
295
+ switch (identifier) {
296
+ case "name":
297
+ result.name = ce.arguments[0].expression.value;
298
+ getPropertyInfo(ce.callee.object, result);
299
+ break;
300
+ case "vModel":
301
+ result.type = DefineVueType.Model;
302
+ result.propertyTypeAsString = extractTypeValue(ce.typeArguments.params[0]);
303
+ result.name = result.name ? `v-model:${result.name}` : result.name;
304
+ break;
305
+ case "slots":
306
+ result.type = DefineVueType.Slot;
307
+ result.propertyTypeAsObject = {};
308
+ ce.typeArguments.params[0].members
309
+ .forEach(m => {
310
+ result.propertyTypeAsObject[m.key.value] = extractTypeValue(m.typeAnnotation);
311
+ });
312
+ break;
313
+ case "prop":
314
+ result.type = DefineVueType.Prop;
315
+ result.propertyTypeAsString = extractTypeValue(ce.typeArguments.params[0]);
316
+ break;
317
+ case "emit":
318
+ result.type = DefineVueType.Emit;
319
+ result.propertyTypeAsString = extractTypeValue(ce.typeArguments.params[0]);
320
+ break;
321
+ default:
322
+ getPropertyInfo(ce.callee.object, result);
323
+ }
324
+ }
325
+ }
326
+ function replaceComponentNamespace(content) {
327
+ const infos = outputInfos.concat(ConfigurationManager.outputInfo.get());
37
328
  infos.forEach(info => {
38
- if (info.wc?.namespace) {
39
- content = content.replace(new RegExp(`(<|<\/|\\s)${info.wc.namespace}\\..*?(>|\\s)`, 'g'), function (match) {
40
- return match.replace(new RegExp(`(${info.wc.namespace}.*)(?=(>|\\s))`), function (token) {
41
- return token.replace(/(\S+)/g, function (tag) {
42
- return info.wc.mappings[tag.replace(`${info.wc.namespace}.`, "")] || tag;
329
+ if (info.wc?.namespaces) {
330
+ info.wc.namespaces.forEach(namespace => {
331
+ content = content.replace(new RegExp(`(<|<\/|\\s)${namespace}\\..*?(>|\\s)`, 'g'), function (match) {
332
+ return match.replace(new RegExp(`(${namespace}.*)(?=(>|\\s))`), function (token) {
333
+ return token.replace(/(\S+)/g, function (tag) {
334
+ // console.log("replaceWebComponentNamespaceMapping", tag)
335
+ return info.wc.mappings[tag.replace("$", "")] || tag;
336
+ });
43
337
  });
44
338
  });
45
339
  });
@@ -62,31 +356,24 @@ function convertManifestPathToEntryPath(pathToManifest, pathsInManifest) {
62
356
  return result;
63
357
  }
64
358
  exports.convertManifestPathToEntryPath = convertManifestPathToEntryPath;
65
- exports.buildContext = {
66
- isManifestsChanged: false
67
- };
68
- exports.cacheKeys = {
69
- //buildManifestMetadatas: "buildManifestMetadatas",
70
- bundleManifests: "bundleManifests"
71
- };
72
359
  class ConfigurationManager {
73
360
  static get webComponentTypings() {
74
361
  if (!this._webComponentTypings) {
75
- this._webComponentTypings = new WebComponentTypingsManagaer();
362
+ this._webComponentTypings = new ImplementComponentTyping();
76
363
  }
77
364
  return this._webComponentTypings;
78
365
  }
79
366
  static get outputInfo() {
80
367
  if (!this._outputInfoManagaer) {
81
- this._outputInfoManagaer = new OutputInfoManagaer();
368
+ this._outputInfoManagaer = new OutputInfoManager();
82
369
  }
83
370
  return this._outputInfoManagaer;
84
371
  }
85
372
  }
373
+ exports.ConfigurationManager = ConfigurationManager;
86
374
  ConfigurationManager._webComponentTypings = null;
87
375
  ConfigurationManager._outputInfoManagaer = null;
88
- exports.ConfigurationManager = ConfigurationManager;
89
- class OutputInfoManagaer {
376
+ class OutputInfoManager {
90
377
  constructor() {
91
378
  this.filePath = exports.isExtensionEnv ? path_1.default.resolve(__dirname, "tooling.output.json") : path_1.default.resolve(__dirname, "config/tooling.output.json");
92
379
  this._value = null;
@@ -104,7 +391,7 @@ class OutputInfoManagaer {
104
391
  return this._value;
105
392
  }
106
393
  }
107
- class WebComponentTypingsManagaer {
394
+ class ImplementComponentTyping {
108
395
  constructor() {
109
396
  this.filePath = exports.isExtensionEnv ? path_1.default.resolve(__dirname, "wctypings.ts") : path_1.default.resolve(__dirname, "config/wctypings.ts");
110
397
  }