@jscutlery/playwright-ct-angular 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -89
- package/{src/register.d.ts → cli.js} +6 -3
- package/hooks.cjs.js +4 -19
- package/hooks.esm.js +4 -19
- package/index.cjs.js +39 -84
- package/index.esm.js +31 -82
- package/package.json +11 -11
- package/register-source.mjs +121 -41
- package/src/hooks.d.ts +9 -2
- package/src/index.d.ts +39 -19
- package/src/transform-angular.d.ts +29 -0
- package/transform-angular.cjs.d.ts +2 -0
- package/transform-angular.cjs.default.js +1 -0
- package/transform-angular.cjs.js +224 -0
- package/transform-angular.cjs.mjs +2 -0
- package/transform-angular.esm.d.ts +2 -0
- package/transform-angular.esm.js +218 -0
- package/register.cjs.d.ts +0 -2
- package/register.cjs.default.js +0 -1
- package/register.cjs.js +0 -88
- package/register.cjs.mjs +0 -2
- package/register.esm.d.ts +0 -2
- package/register.esm.js +0 -86
- package/src/lib/playwright-ct-angular.d.ts +0 -1062
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('node:path');
|
|
4
|
+
var core = require('@babel/core');
|
|
5
|
+
var transform = require('playwright/lib/transform/transform');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
10
|
+
|
|
11
|
+
var lib = {};
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(lib, "__esModule", {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var declare_1 = lib.declare = declare;
|
|
17
|
+
lib.declarePreset = void 0;
|
|
18
|
+
const apiPolyfills = {
|
|
19
|
+
assertVersion: api => range => {
|
|
20
|
+
throwVersionError(range, api.version);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
{
|
|
24
|
+
Object.assign(apiPolyfills, {
|
|
25
|
+
targets: () => () => {
|
|
26
|
+
return {};
|
|
27
|
+
},
|
|
28
|
+
assumption: () => () => {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function declare(builder) {
|
|
34
|
+
return (api, options, dirname) => {
|
|
35
|
+
var _clonedApi2;
|
|
36
|
+
let clonedApi;
|
|
37
|
+
for (const name of Object.keys(apiPolyfills)) {
|
|
38
|
+
var _clonedApi;
|
|
39
|
+
if (api[name]) continue;
|
|
40
|
+
(_clonedApi = clonedApi) != null ? _clonedApi : clonedApi = copyApiObject(api);
|
|
41
|
+
clonedApi[name] = apiPolyfills[name](clonedApi);
|
|
42
|
+
}
|
|
43
|
+
return builder((_clonedApi2 = clonedApi) != null ? _clonedApi2 : api, options || {}, dirname);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
lib.declarePreset = declare;
|
|
47
|
+
function copyApiObject(api) {
|
|
48
|
+
let proto = null;
|
|
49
|
+
if (typeof api.version === "string" && /^7\./.test(api.version)) {
|
|
50
|
+
proto = Object.getPrototypeOf(api);
|
|
51
|
+
if (proto && (!hasOwnProperty.call(proto, "version") || !hasOwnProperty.call(proto, "transform") || !hasOwnProperty.call(proto, "template") || !hasOwnProperty.call(proto, "types"))) {
|
|
52
|
+
proto = null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return Object.assign({}, proto, api);
|
|
56
|
+
}
|
|
57
|
+
function throwVersionError(range, version) {
|
|
58
|
+
if (typeof range === "number") {
|
|
59
|
+
if (!Number.isInteger(range)) {
|
|
60
|
+
throw new Error("Expected string or integer value.");
|
|
61
|
+
}
|
|
62
|
+
range = `^${range}.0.0-0`;
|
|
63
|
+
}
|
|
64
|
+
if (typeof range !== "string") {
|
|
65
|
+
throw new Error("Expected string or integer value.");
|
|
66
|
+
}
|
|
67
|
+
const limit = Error.stackTraceLimit;
|
|
68
|
+
if (typeof limit === "number" && limit < 25) {
|
|
69
|
+
Error.stackTraceLimit = 25;
|
|
70
|
+
}
|
|
71
|
+
let err;
|
|
72
|
+
if (version.slice(0, 2) === "7.") {
|
|
73
|
+
err = new Error(`Requires Babel "^7.0.0-beta.41", but was loaded with "${version}". ` + `You'll need to update your @babel/core version.`);
|
|
74
|
+
} else {
|
|
75
|
+
err = new Error(`Requires Babel "${range}", but was loaded with "${version}". ` + `If you are sure you have a compatible version of @babel/core, ` + `it is likely that something in your build process is loading the ` + `wrong version. Inspect the stack trace of this error to look for ` + `the first entry that doesn't mention "@babel/core" or "babel-core" ` + `to see what is calling Babel.`);
|
|
76
|
+
}
|
|
77
|
+
if (typeof limit === "number") {
|
|
78
|
+
Error.stackTraceLimit = limit;
|
|
79
|
+
}
|
|
80
|
+
throw Object.assign(err, {
|
|
81
|
+
code: "BABEL_VERSION_UNSUPPORTED",
|
|
82
|
+
version,
|
|
83
|
+
range
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Copyright (c) Microsoft Corporation.
|
|
89
|
+
*
|
|
90
|
+
* Licensed under the Apache License, Version 2.0 (the 'License');
|
|
91
|
+
* you may not use this file except in compliance with the License.
|
|
92
|
+
* You may obtain a copy of the License at
|
|
93
|
+
*
|
|
94
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
95
|
+
*
|
|
96
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
97
|
+
* distributed under the License is distributed on an 'AS IS' BASIS,
|
|
98
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
99
|
+
* See the License for the specific language governing permissions and
|
|
100
|
+
* limitations under the License.
|
|
101
|
+
*
|
|
102
|
+
* Original file: https://github.com/microsoft/playwright/blob/8173cdc4857f8e0a98047e02e692c5da6544a170/packages/playwright-ct-core/src/tsxTransform.ts
|
|
103
|
+
*/
|
|
104
|
+
let classComponentNames;
|
|
105
|
+
let importInfos;
|
|
106
|
+
var transformAngular = declare_1((api) => {
|
|
107
|
+
api.assertVersion(7);
|
|
108
|
+
return {
|
|
109
|
+
name: 'jscutlery-playwright-angular-transform',
|
|
110
|
+
visitor: {
|
|
111
|
+
Program: {
|
|
112
|
+
enter(path) {
|
|
113
|
+
classComponentNames = collectClassMountUsages(path);
|
|
114
|
+
importInfos = new Map();
|
|
115
|
+
},
|
|
116
|
+
exit(path) {
|
|
117
|
+
// @eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
let firstDeclaration;
|
|
119
|
+
// @eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
+
let lastImportDeclaration;
|
|
121
|
+
path.get('body').forEach((p) => {
|
|
122
|
+
if (p.isImportDeclaration())
|
|
123
|
+
lastImportDeclaration = p;
|
|
124
|
+
else if (!firstDeclaration)
|
|
125
|
+
firstDeclaration = p;
|
|
126
|
+
});
|
|
127
|
+
const insertionPath = lastImportDeclaration || firstDeclaration;
|
|
128
|
+
if (!insertionPath)
|
|
129
|
+
return;
|
|
130
|
+
for (const [localName, componentImport] of [
|
|
131
|
+
...importInfos.entries(),
|
|
132
|
+
].reverse()) {
|
|
133
|
+
insertionPath.insertAfter(core.types.variableDeclaration('const', [
|
|
134
|
+
core.types.variableDeclarator(core.types.identifier(localName), core.types.objectExpression([
|
|
135
|
+
core.types.objectProperty(core.types.identifier('__pw_type'), core.types.stringLiteral('importRef')),
|
|
136
|
+
core.types.objectProperty(core.types.identifier('id'), core.types.stringLiteral(componentImport.id)),
|
|
137
|
+
])),
|
|
138
|
+
]));
|
|
139
|
+
}
|
|
140
|
+
transform.setTransformData('playwright-ct-core', [...importInfos.values()]);
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
ImportDeclaration(p) {
|
|
144
|
+
const importNode = p.node;
|
|
145
|
+
if (!core.types.isStringLiteral(importNode.source)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
// Convert JS imports that are used as components in JSX expressions into refs.
|
|
149
|
+
let importCount = 0;
|
|
150
|
+
for (const specifier of importNode.specifiers) {
|
|
151
|
+
if (core.types.isImportNamespaceSpecifier(specifier))
|
|
152
|
+
continue;
|
|
153
|
+
const { localName, info } = importInfo(importNode, specifier,
|
|
154
|
+
// @eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
155
|
+
this.filename);
|
|
156
|
+
if (classComponentNames.has(localName)) {
|
|
157
|
+
importInfos.set(localName, info);
|
|
158
|
+
++importCount;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// All the imports were from JSX => delete.
|
|
162
|
+
if (importCount && importCount === importNode.specifiers.length) {
|
|
163
|
+
p.skip();
|
|
164
|
+
p.remove();
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
function collectClassMountUsages(path) {
|
|
171
|
+
const names = new Set();
|
|
172
|
+
let isInMountCall = false;
|
|
173
|
+
path.traverse({
|
|
174
|
+
CallExpression: {
|
|
175
|
+
enter(p) {
|
|
176
|
+
if (core.types.isIdentifier(p.node.callee) && p.node.callee.name === 'mount') {
|
|
177
|
+
isInMountCall = true;
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
/* Ignore any function or method calls in `mount` args.
|
|
181
|
+
* e.g. {inputs: {recipe: recipeMother.withBasicInfo()}}. */
|
|
182
|
+
if (isInMountCall) {
|
|
183
|
+
p.skip();
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
exit() {
|
|
187
|
+
isInMountCall = false;
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
Identifier(p) {
|
|
191
|
+
if (isInMountCall) {
|
|
192
|
+
names.add(p.node.name);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
return names;
|
|
197
|
+
}
|
|
198
|
+
function importInfo(importNode, specifier, filename) {
|
|
199
|
+
const importSource = importNode.source.value;
|
|
200
|
+
const idPrefix = path__default["default"]
|
|
201
|
+
.join(filename, '..', importSource)
|
|
202
|
+
.replace(/[^\w_\d]/g, '_');
|
|
203
|
+
const result = {
|
|
204
|
+
id: idPrefix,
|
|
205
|
+
filename,
|
|
206
|
+
importSource,
|
|
207
|
+
remoteName: undefined,
|
|
208
|
+
};
|
|
209
|
+
// @eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
210
|
+
const imported = specifier.imported;
|
|
211
|
+
if (!core.types.isImportDefaultSpecifier(specifier)) {
|
|
212
|
+
if (core.types.isIdentifier(imported)) {
|
|
213
|
+
result.remoteName = imported.name;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
result.remoteName = imported.value;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (result.remoteName)
|
|
220
|
+
result.id += '_' + result.remoteName;
|
|
221
|
+
return { localName: specifier.local.name, info: result };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
module.exports = transformAngular;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import path__default from 'node:path';
|
|
2
|
+
import { types } from '@babel/core';
|
|
3
|
+
import { setTransformData } from 'playwright/lib/transform/transform';
|
|
4
|
+
|
|
5
|
+
var lib = {};
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(lib, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
var declare_1 = lib.declare = declare;
|
|
11
|
+
lib.declarePreset = void 0;
|
|
12
|
+
const apiPolyfills = {
|
|
13
|
+
assertVersion: api => range => {
|
|
14
|
+
throwVersionError(range, api.version);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
{
|
|
18
|
+
Object.assign(apiPolyfills, {
|
|
19
|
+
targets: () => () => {
|
|
20
|
+
return {};
|
|
21
|
+
},
|
|
22
|
+
assumption: () => () => {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function declare(builder) {
|
|
28
|
+
return (api, options, dirname) => {
|
|
29
|
+
var _clonedApi2;
|
|
30
|
+
let clonedApi;
|
|
31
|
+
for (const name of Object.keys(apiPolyfills)) {
|
|
32
|
+
var _clonedApi;
|
|
33
|
+
if (api[name]) continue;
|
|
34
|
+
(_clonedApi = clonedApi) != null ? _clonedApi : clonedApi = copyApiObject(api);
|
|
35
|
+
clonedApi[name] = apiPolyfills[name](clonedApi);
|
|
36
|
+
}
|
|
37
|
+
return builder((_clonedApi2 = clonedApi) != null ? _clonedApi2 : api, options || {}, dirname);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
lib.declarePreset = declare;
|
|
41
|
+
function copyApiObject(api) {
|
|
42
|
+
let proto = null;
|
|
43
|
+
if (typeof api.version === "string" && /^7\./.test(api.version)) {
|
|
44
|
+
proto = Object.getPrototypeOf(api);
|
|
45
|
+
if (proto && (!hasOwnProperty.call(proto, "version") || !hasOwnProperty.call(proto, "transform") || !hasOwnProperty.call(proto, "template") || !hasOwnProperty.call(proto, "types"))) {
|
|
46
|
+
proto = null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return Object.assign({}, proto, api);
|
|
50
|
+
}
|
|
51
|
+
function throwVersionError(range, version) {
|
|
52
|
+
if (typeof range === "number") {
|
|
53
|
+
if (!Number.isInteger(range)) {
|
|
54
|
+
throw new Error("Expected string or integer value.");
|
|
55
|
+
}
|
|
56
|
+
range = `^${range}.0.0-0`;
|
|
57
|
+
}
|
|
58
|
+
if (typeof range !== "string") {
|
|
59
|
+
throw new Error("Expected string or integer value.");
|
|
60
|
+
}
|
|
61
|
+
const limit = Error.stackTraceLimit;
|
|
62
|
+
if (typeof limit === "number" && limit < 25) {
|
|
63
|
+
Error.stackTraceLimit = 25;
|
|
64
|
+
}
|
|
65
|
+
let err;
|
|
66
|
+
if (version.slice(0, 2) === "7.") {
|
|
67
|
+
err = new Error(`Requires Babel "^7.0.0-beta.41", but was loaded with "${version}". ` + `You'll need to update your @babel/core version.`);
|
|
68
|
+
} else {
|
|
69
|
+
err = new Error(`Requires Babel "${range}", but was loaded with "${version}". ` + `If you are sure you have a compatible version of @babel/core, ` + `it is likely that something in your build process is loading the ` + `wrong version. Inspect the stack trace of this error to look for ` + `the first entry that doesn't mention "@babel/core" or "babel-core" ` + `to see what is calling Babel.`);
|
|
70
|
+
}
|
|
71
|
+
if (typeof limit === "number") {
|
|
72
|
+
Error.stackTraceLimit = limit;
|
|
73
|
+
}
|
|
74
|
+
throw Object.assign(err, {
|
|
75
|
+
code: "BABEL_VERSION_UNSUPPORTED",
|
|
76
|
+
version,
|
|
77
|
+
range
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Copyright (c) Microsoft Corporation.
|
|
83
|
+
*
|
|
84
|
+
* Licensed under the Apache License, Version 2.0 (the 'License');
|
|
85
|
+
* you may not use this file except in compliance with the License.
|
|
86
|
+
* You may obtain a copy of the License at
|
|
87
|
+
*
|
|
88
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
89
|
+
*
|
|
90
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
91
|
+
* distributed under the License is distributed on an 'AS IS' BASIS,
|
|
92
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
93
|
+
* See the License for the specific language governing permissions and
|
|
94
|
+
* limitations under the License.
|
|
95
|
+
*
|
|
96
|
+
* Original file: https://github.com/microsoft/playwright/blob/8173cdc4857f8e0a98047e02e692c5da6544a170/packages/playwright-ct-core/src/tsxTransform.ts
|
|
97
|
+
*/
|
|
98
|
+
let classComponentNames;
|
|
99
|
+
let importInfos;
|
|
100
|
+
var transformAngular = declare_1((api) => {
|
|
101
|
+
api.assertVersion(7);
|
|
102
|
+
return {
|
|
103
|
+
name: 'jscutlery-playwright-angular-transform',
|
|
104
|
+
visitor: {
|
|
105
|
+
Program: {
|
|
106
|
+
enter(path) {
|
|
107
|
+
classComponentNames = collectClassMountUsages(path);
|
|
108
|
+
importInfos = new Map();
|
|
109
|
+
},
|
|
110
|
+
exit(path) {
|
|
111
|
+
// @eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
112
|
+
let firstDeclaration;
|
|
113
|
+
// @eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
let lastImportDeclaration;
|
|
115
|
+
path.get('body').forEach((p) => {
|
|
116
|
+
if (p.isImportDeclaration())
|
|
117
|
+
lastImportDeclaration = p;
|
|
118
|
+
else if (!firstDeclaration)
|
|
119
|
+
firstDeclaration = p;
|
|
120
|
+
});
|
|
121
|
+
const insertionPath = lastImportDeclaration || firstDeclaration;
|
|
122
|
+
if (!insertionPath)
|
|
123
|
+
return;
|
|
124
|
+
for (const [localName, componentImport] of [
|
|
125
|
+
...importInfos.entries(),
|
|
126
|
+
].reverse()) {
|
|
127
|
+
insertionPath.insertAfter(types.variableDeclaration('const', [
|
|
128
|
+
types.variableDeclarator(types.identifier(localName), types.objectExpression([
|
|
129
|
+
types.objectProperty(types.identifier('__pw_type'), types.stringLiteral('importRef')),
|
|
130
|
+
types.objectProperty(types.identifier('id'), types.stringLiteral(componentImport.id)),
|
|
131
|
+
])),
|
|
132
|
+
]));
|
|
133
|
+
}
|
|
134
|
+
setTransformData('playwright-ct-core', [...importInfos.values()]);
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
ImportDeclaration(p) {
|
|
138
|
+
const importNode = p.node;
|
|
139
|
+
if (!types.isStringLiteral(importNode.source)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// Convert JS imports that are used as components in JSX expressions into refs.
|
|
143
|
+
let importCount = 0;
|
|
144
|
+
for (const specifier of importNode.specifiers) {
|
|
145
|
+
if (types.isImportNamespaceSpecifier(specifier))
|
|
146
|
+
continue;
|
|
147
|
+
const { localName, info } = importInfo(importNode, specifier,
|
|
148
|
+
// @eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
149
|
+
this.filename);
|
|
150
|
+
if (classComponentNames.has(localName)) {
|
|
151
|
+
importInfos.set(localName, info);
|
|
152
|
+
++importCount;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// All the imports were from JSX => delete.
|
|
156
|
+
if (importCount && importCount === importNode.specifiers.length) {
|
|
157
|
+
p.skip();
|
|
158
|
+
p.remove();
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
function collectClassMountUsages(path) {
|
|
165
|
+
const names = new Set();
|
|
166
|
+
let isInMountCall = false;
|
|
167
|
+
path.traverse({
|
|
168
|
+
CallExpression: {
|
|
169
|
+
enter(p) {
|
|
170
|
+
if (types.isIdentifier(p.node.callee) && p.node.callee.name === 'mount') {
|
|
171
|
+
isInMountCall = true;
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
/* Ignore any function or method calls in `mount` args.
|
|
175
|
+
* e.g. {inputs: {recipe: recipeMother.withBasicInfo()}}. */
|
|
176
|
+
if (isInMountCall) {
|
|
177
|
+
p.skip();
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
exit() {
|
|
181
|
+
isInMountCall = false;
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
Identifier(p) {
|
|
185
|
+
if (isInMountCall) {
|
|
186
|
+
names.add(p.node.name);
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
return names;
|
|
191
|
+
}
|
|
192
|
+
function importInfo(importNode, specifier, filename) {
|
|
193
|
+
const importSource = importNode.source.value;
|
|
194
|
+
const idPrefix = path__default
|
|
195
|
+
.join(filename, '..', importSource)
|
|
196
|
+
.replace(/[^\w_\d]/g, '_');
|
|
197
|
+
const result = {
|
|
198
|
+
id: idPrefix,
|
|
199
|
+
filename,
|
|
200
|
+
importSource,
|
|
201
|
+
remoteName: undefined,
|
|
202
|
+
};
|
|
203
|
+
// @eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
204
|
+
const imported = specifier.imported;
|
|
205
|
+
if (!types.isImportDefaultSpecifier(specifier)) {
|
|
206
|
+
if (types.isIdentifier(imported)) {
|
|
207
|
+
result.remoteName = imported.name;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
result.remoteName = imported.value;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (result.remoteName)
|
|
214
|
+
result.id += '_' + result.remoteName;
|
|
215
|
+
return { localName: specifier.local.name, info: result };
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { transformAngular as default };
|
package/register.cjs.d.ts
DELETED
package/register.cjs.default.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
exports._default = require('./register.cjs.js').default;
|
package/register.cjs.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('@angular/compiler');
|
|
4
|
-
require('zone.js');
|
|
5
|
-
var testing = require('@angular/core/testing');
|
|
6
|
-
var testing$1 = require('@angular/platform-browser-dynamic/testing');
|
|
7
|
-
var animations = require('@angular/platform-browser/animations');
|
|
8
|
-
var rxjs = require('rxjs');
|
|
9
|
-
|
|
10
|
-
const _componentLoaderMap = new Map();
|
|
11
|
-
|
|
12
|
-
testing.getTestBed().initTestEnvironment(
|
|
13
|
-
testing$1.BrowserDynamicTestingModule,
|
|
14
|
-
testing$1.platformBrowserDynamicTesting()
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* This is the function used by Playwright CT to map each component to its symbol.
|
|
19
|
-
* The key here is a slug generated by Playwright CT based on the component's module path + component's name.
|
|
20
|
-
*/
|
|
21
|
-
function pwRegister(components) {
|
|
22
|
-
for (const [name, value] of Object.entries(components)) {
|
|
23
|
-
_componentLoaderMap.set(name, value);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Container subscription holding all outputs subscription
|
|
29
|
-
* in order to unsubscribe when component is unmounted.
|
|
30
|
-
*/
|
|
31
|
-
let subscription;
|
|
32
|
-
|
|
33
|
-
globalThis.playwrightMount = async (component, rootElement, hooksConfig) => {
|
|
34
|
-
const loader = _componentLoaderMap.get(component.type);
|
|
35
|
-
const cmpType = await loader();
|
|
36
|
-
|
|
37
|
-
subscription = new rxjs.Subscription();
|
|
38
|
-
|
|
39
|
-
testing.TestBed.configureTestingModule({
|
|
40
|
-
imports: [animations.BrowserAnimationsModule],
|
|
41
|
-
});
|
|
42
|
-
const fixture = testing.TestBed.createComponent(cmpType);
|
|
43
|
-
|
|
44
|
-
/* Set inputs. */
|
|
45
|
-
for (const [name, value] of Object.entries(component.options.inputs ?? {})) {
|
|
46
|
-
fixture.componentInstance[name] = value;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/* Subscribe to outputs. */
|
|
50
|
-
for (const [name, callback] of Object.entries(
|
|
51
|
-
component.options.outputs ?? {}
|
|
52
|
-
)) {
|
|
53
|
-
subscription.add(fixture.componentInstance[name].subscribe(callback));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
fixture.autoDetectChanges();
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
globalThis.playwrightUnmount = async (rootElement) => {
|
|
60
|
-
subscription.unsubscribe();
|
|
61
|
-
subscription = null;
|
|
62
|
-
testing.getTestBed().resetTestingModule();
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
globalThis.playwrightUpdate = async (rootElement, component) => {
|
|
66
|
-
rootElement.innerHTML = component;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Copyright (c) Microsoft Corporation.
|
|
71
|
-
*
|
|
72
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
73
|
-
* you may not use this file except in compliance with the License.
|
|
74
|
-
* You may obtain a copy of the License at
|
|
75
|
-
*
|
|
76
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
77
|
-
*
|
|
78
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
79
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
80
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
81
|
-
* See the License for the specific language governing permissions and
|
|
82
|
-
* limitations under the License.
|
|
83
|
-
*/
|
|
84
|
-
var register = (components) => {
|
|
85
|
-
pwRegister(components);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
module.exports = register;
|
package/register.cjs.mjs
DELETED
package/register.esm.d.ts
DELETED
package/register.esm.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import '@angular/compiler';
|
|
2
|
-
import 'zone.js';
|
|
3
|
-
import { getTestBed, TestBed } from '@angular/core/testing';
|
|
4
|
-
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
|
5
|
-
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
6
|
-
import { Subscription } from 'rxjs';
|
|
7
|
-
|
|
8
|
-
const _componentLoaderMap = new Map();
|
|
9
|
-
|
|
10
|
-
getTestBed().initTestEnvironment(
|
|
11
|
-
BrowserDynamicTestingModule,
|
|
12
|
-
platformBrowserDynamicTesting()
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* This is the function used by Playwright CT to map each component to its symbol.
|
|
17
|
-
* The key here is a slug generated by Playwright CT based on the component's module path + component's name.
|
|
18
|
-
*/
|
|
19
|
-
function pwRegister(components) {
|
|
20
|
-
for (const [name, value] of Object.entries(components)) {
|
|
21
|
-
_componentLoaderMap.set(name, value);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Container subscription holding all outputs subscription
|
|
27
|
-
* in order to unsubscribe when component is unmounted.
|
|
28
|
-
*/
|
|
29
|
-
let subscription;
|
|
30
|
-
|
|
31
|
-
globalThis.playwrightMount = async (component, rootElement, hooksConfig) => {
|
|
32
|
-
const loader = _componentLoaderMap.get(component.type);
|
|
33
|
-
const cmpType = await loader();
|
|
34
|
-
|
|
35
|
-
subscription = new Subscription();
|
|
36
|
-
|
|
37
|
-
TestBed.configureTestingModule({
|
|
38
|
-
imports: [BrowserAnimationsModule],
|
|
39
|
-
});
|
|
40
|
-
const fixture = TestBed.createComponent(cmpType);
|
|
41
|
-
|
|
42
|
-
/* Set inputs. */
|
|
43
|
-
for (const [name, value] of Object.entries(component.options.inputs ?? {})) {
|
|
44
|
-
fixture.componentInstance[name] = value;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/* Subscribe to outputs. */
|
|
48
|
-
for (const [name, callback] of Object.entries(
|
|
49
|
-
component.options.outputs ?? {}
|
|
50
|
-
)) {
|
|
51
|
-
subscription.add(fixture.componentInstance[name].subscribe(callback));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
fixture.autoDetectChanges();
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
globalThis.playwrightUnmount = async (rootElement) => {
|
|
58
|
-
subscription.unsubscribe();
|
|
59
|
-
subscription = null;
|
|
60
|
-
getTestBed().resetTestingModule();
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
globalThis.playwrightUpdate = async (rootElement, component) => {
|
|
64
|
-
rootElement.innerHTML = component;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Copyright (c) Microsoft Corporation.
|
|
69
|
-
*
|
|
70
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
71
|
-
* you may not use this file except in compliance with the License.
|
|
72
|
-
* You may obtain a copy of the License at
|
|
73
|
-
*
|
|
74
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
75
|
-
*
|
|
76
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
77
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
78
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
79
|
-
* See the License for the specific language governing permissions and
|
|
80
|
-
* limitations under the License.
|
|
81
|
-
*/
|
|
82
|
-
var register = (components) => {
|
|
83
|
-
pwRegister(components);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export { register as default };
|