@iflyrpa/playwright 1.0.6 → 1.0.7

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/dist/index.cjs CHANGED
@@ -18,7 +18,7 @@ const spawn__default = /*#__PURE__*/_interopDefaultCompat(spawn);
18
18
 
19
19
  const name = "@iflyrpa/playwright";
20
20
  const type = "module";
21
- const version$1 = "1.0.6";
21
+ const version$1 = "1.0.7";
22
22
  const description = "";
23
23
  const main = "./dist/index.cjs";
24
24
  const module$1 = "./dist/index.mjs";
@@ -138,52 +138,56 @@ const xiaohongshuPublishAction = async (props) => {
138
138
  const container = page.locator(".creator-container .content .scroll-content");
139
139
  await container.focus();
140
140
  await page.mouse.wheel(0, 500);
141
- await selectAddress(
142
- ".media-extension .address-input input[placeholder=\u6DFB\u52A0\u5730\u70B9]",
143
- params.address
144
- );
145
- await page.locator(".declaration-wrapper").click();
146
- const selfDeclarationInstance = page.locator(
147
- ".el-popper[aria-hidden=false] ul li[role=menuitem]"
148
- );
149
- if (params.selfDeclaration.type === "fictional-rendition") {
150
- await selfDeclarationInstance.filter({ hasText: "\u865A\u6784\u6F14\u7ECE\uFF0C\u4EC5\u4F9B\u5A31\u4E50" }).click();
151
- } else if (params.selfDeclaration.type === "ai-generated") {
152
- await selfDeclarationInstance.filter({ hasText: "\u7B14\u8BB0\u542BAI\u5408\u6210\u5185\u5BB9" }).click();
153
- } else if (params.selfDeclaration.type === "source-statement") {
154
- await selfDeclarationInstance.filter({ hasText: "\u5185\u5BB9\u6765\u6E90\u58F0\u660E" }).click();
155
- const selfDeclarationSecondaryMenuInstance = page.locator(".el-popper[aria-hidden=false] .el-cascader-menu").nth(1).locator("ul li[role=menuitem]");
156
- await selfDeclarationSecondaryMenuInstance.first().waitFor();
157
- if (params.selfDeclaration.childType === "self-labeling") {
158
- await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u5DF2\u81EA\u4E3B\u6807\u6CE8" }).click();
159
- } else if (params.selfDeclaration.childType === "self-shooting") {
160
- const { shootingDate, shootingLocation } = params.selfDeclaration;
161
- await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u81EA\u4E3B\u62CD\u6444" }).click();
162
- const selfShootingPopup = page.locator(".el-overlay-dialog[aria-modal=true][role=dialog]").filter({ hasText: "\u81EA\u4E3B\u62CD\u6444" });
163
- await selfShootingPopup.waitFor();
164
- const hasCustomContent = shootingDate || shootingLocation;
165
- if (shootingLocation) {
166
- await selectAddress(
167
- selfShootingPopup.locator(".address-input input"),
168
- shootingLocation
169
- );
170
- }
171
- if (shootingDate) {
172
- await selectDate(
173
- selfShootingPopup.locator(".date-picker input"),
174
- shootingDate
175
- );
176
- }
177
- await selfShootingPopup.locator("footer button").filter({ hasText: hasCustomContent ? "\u786E\u8BA4" : "\u53D6\u6D88" }).click();
178
- } else if (params.selfDeclaration.childType === "transshipment") {
179
- await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u6765\u6E90\u8F6C\u8F7D" }).click();
180
- const selfShootingPopup = page.locator(".el-overlay-dialog[aria-modal=true][role=dialog]").filter({ hasText: "\u6765\u6E90\u5A92\u4F53" });
181
- await selfShootingPopup.waitFor();
182
- const sourceMedia = params.selfDeclaration.sourceMedia;
183
- if (sourceMedia) {
184
- await selfShootingPopup.locator(".el-input input").fill(sourceMedia);
141
+ if (params.address) {
142
+ await selectAddress(
143
+ ".media-extension .address-input input[placeholder=\u6DFB\u52A0\u5730\u70B9]",
144
+ params.address
145
+ );
146
+ }
147
+ if (params.selfDeclaration) {
148
+ await page.locator(".declaration-wrapper").click();
149
+ const selfDeclarationInstance = page.locator(
150
+ ".el-popper[aria-hidden=false] ul li[role=menuitem]"
151
+ );
152
+ if (params.selfDeclaration.type === "fictional-rendition") {
153
+ await selfDeclarationInstance.filter({ hasText: "\u865A\u6784\u6F14\u7ECE\uFF0C\u4EC5\u4F9B\u5A31\u4E50" }).click();
154
+ } else if (params.selfDeclaration.type === "ai-generated") {
155
+ await selfDeclarationInstance.filter({ hasText: "\u7B14\u8BB0\u542BAI\u5408\u6210\u5185\u5BB9" }).click();
156
+ } else if (params.selfDeclaration.type === "source-statement") {
157
+ await selfDeclarationInstance.filter({ hasText: "\u5185\u5BB9\u6765\u6E90\u58F0\u660E" }).click();
158
+ const selfDeclarationSecondaryMenuInstance = page.locator(".el-popper[aria-hidden=false] .el-cascader-menu").nth(1).locator("ul li[role=menuitem]");
159
+ await selfDeclarationSecondaryMenuInstance.first().waitFor();
160
+ if (params.selfDeclaration.childType === "self-labeling") {
161
+ await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u5DF2\u81EA\u4E3B\u6807\u6CE8" }).click();
162
+ } else if (params.selfDeclaration.childType === "self-shooting") {
163
+ const { shootingDate, shootingLocation } = params.selfDeclaration;
164
+ await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u81EA\u4E3B\u62CD\u6444" }).click();
165
+ const selfShootingPopup = page.locator(".el-overlay-dialog[aria-modal=true][role=dialog]").filter({ hasText: "\u81EA\u4E3B\u62CD\u6444" });
166
+ await selfShootingPopup.waitFor();
167
+ const hasCustomContent = shootingDate || shootingLocation;
168
+ if (shootingLocation) {
169
+ await selectAddress(
170
+ selfShootingPopup.locator(".address-input input"),
171
+ shootingLocation
172
+ );
173
+ }
174
+ if (shootingDate) {
175
+ await selectDate(
176
+ selfShootingPopup.locator(".date-picker input"),
177
+ shootingDate
178
+ );
179
+ }
180
+ await selfShootingPopup.locator("footer button").filter({ hasText: hasCustomContent ? "\u786E\u8BA4" : "\u53D6\u6D88" }).click();
181
+ } else if (params.selfDeclaration.childType === "transshipment") {
182
+ await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u6765\u6E90\u8F6C\u8F7D" }).click();
183
+ const selfShootingPopup = page.locator(".el-overlay-dialog[aria-modal=true][role=dialog]").filter({ hasText: "\u6765\u6E90\u5A92\u4F53" });
184
+ await selfShootingPopup.waitFor();
185
+ const sourceMedia = params.selfDeclaration.sourceMedia;
186
+ if (sourceMedia) {
187
+ await selfShootingPopup.locator(".el-input input").fill(sourceMedia);
188
+ }
189
+ await selfShootingPopup.locator("footer button").filter({ hasText: sourceMedia ? "\u786E\u8BA4" : "\u53D6\u6D88" }).click();
185
190
  }
186
- await selfShootingPopup.locator("footer button").filter({ hasText: sourceMedia ? "\u786E\u8BA4" : "\u53D6\u6D88" }).click();
187
191
  }
188
192
  }
189
193
  const publicLabelInstance = page.locator("label").filter({ hasText: visibleRangeTexts[params.visibleRange] });
@@ -352,6 +356,17 @@ class LocalAutomateTask {
352
356
  this.debug = params.debug || false;
353
357
  this.appWhenReady = createElectronApp(params.cachePath);
354
358
  }
359
+ /**
360
+ * 关闭 playwright 启动的 electron 客户端
361
+ * @returns
362
+ */
363
+ async close() {
364
+ const electronApp = await this.appWhenReady;
365
+ return electronApp.close();
366
+ }
367
+ /**
368
+ * 小红书自动化发布
369
+ */
355
370
  async xiaohongshuPublish(params) {
356
371
  const electronApp = await this.appWhenReady;
357
372
  const commonCookies = {
package/dist/index.d.cts CHANGED
@@ -32,8 +32,8 @@ interface XiaohonshuPublishParams
32
32
  banners: string[]; // 图片
33
33
  title: string; // 标题
34
34
  content: string; // 正文
35
- address: string; // 地点
36
- selfDeclaration: SelfDeclaration; // 自主声明
35
+ address?: string; // 地点
36
+ selfDeclaration?: SelfDeclaration; // 自主声明
37
37
  visibleRange: "public" | "private"; // 可见范围
38
38
  isImmediatelyPublish?: boolean; // 是否立即发布
39
39
  scheduledPublish?: string; // 定时发布时间
@@ -48,6 +48,14 @@ declare class LocalAutomateTask implements TaskParams {
48
48
  debug: boolean;
49
49
  appWhenReady: Promise<ElectronApplication>;
50
50
  constructor(params: TaskParams);
51
+ /**
52
+ * 关闭 playwright 启动的 electron 客户端
53
+ * @returns
54
+ */
55
+ close(): Promise<void>;
56
+ /**
57
+ * 小红书自动化发布
58
+ */
51
59
  xiaohongshuPublish(params: XiaohonshuPublishParams): Promise<string>;
52
60
  }
53
61
  declare const RpaTask: (params: TaskParams) => LocalAutomateTask;
package/dist/index.d.mts CHANGED
@@ -32,8 +32,8 @@ interface XiaohonshuPublishParams
32
32
  banners: string[]; // 图片
33
33
  title: string; // 标题
34
34
  content: string; // 正文
35
- address: string; // 地点
36
- selfDeclaration: SelfDeclaration; // 自主声明
35
+ address?: string; // 地点
36
+ selfDeclaration?: SelfDeclaration; // 自主声明
37
37
  visibleRange: "public" | "private"; // 可见范围
38
38
  isImmediatelyPublish?: boolean; // 是否立即发布
39
39
  scheduledPublish?: string; // 定时发布时间
@@ -48,6 +48,14 @@ declare class LocalAutomateTask implements TaskParams {
48
48
  debug: boolean;
49
49
  appWhenReady: Promise<ElectronApplication>;
50
50
  constructor(params: TaskParams);
51
+ /**
52
+ * 关闭 playwright 启动的 electron 客户端
53
+ * @returns
54
+ */
55
+ close(): Promise<void>;
56
+ /**
57
+ * 小红书自动化发布
58
+ */
51
59
  xiaohongshuPublish(params: XiaohonshuPublishParams): Promise<string>;
52
60
  }
53
61
  declare const RpaTask: (params: TaskParams) => LocalAutomateTask;
package/dist/index.d.ts CHANGED
@@ -32,8 +32,8 @@ interface XiaohonshuPublishParams
32
32
  banners: string[]; // 图片
33
33
  title: string; // 标题
34
34
  content: string; // 正文
35
- address: string; // 地点
36
- selfDeclaration: SelfDeclaration; // 自主声明
35
+ address?: string; // 地点
36
+ selfDeclaration?: SelfDeclaration; // 自主声明
37
37
  visibleRange: "public" | "private"; // 可见范围
38
38
  isImmediatelyPublish?: boolean; // 是否立即发布
39
39
  scheduledPublish?: string; // 定时发布时间
@@ -48,6 +48,14 @@ declare class LocalAutomateTask implements TaskParams {
48
48
  debug: boolean;
49
49
  appWhenReady: Promise<ElectronApplication>;
50
50
  constructor(params: TaskParams);
51
+ /**
52
+ * 关闭 playwright 启动的 electron 客户端
53
+ * @returns
54
+ */
55
+ close(): Promise<void>;
56
+ /**
57
+ * 小红书自动化发布
58
+ */
51
59
  xiaohongshuPublish(params: XiaohonshuPublishParams): Promise<string>;
52
60
  }
53
61
  declare const RpaTask: (params: TaskParams) => LocalAutomateTask;
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import spawn from 'cross-spawn';
8
8
 
9
9
  const name = "@iflyrpa/playwright";
10
10
  const type = "module";
11
- const version$1 = "1.0.6";
11
+ const version$1 = "1.0.7";
12
12
  const description = "";
13
13
  const main = "./dist/index.cjs";
14
14
  const module = "./dist/index.mjs";
@@ -128,52 +128,56 @@ const xiaohongshuPublishAction = async (props) => {
128
128
  const container = page.locator(".creator-container .content .scroll-content");
129
129
  await container.focus();
130
130
  await page.mouse.wheel(0, 500);
131
- await selectAddress(
132
- ".media-extension .address-input input[placeholder=\u6DFB\u52A0\u5730\u70B9]",
133
- params.address
134
- );
135
- await page.locator(".declaration-wrapper").click();
136
- const selfDeclarationInstance = page.locator(
137
- ".el-popper[aria-hidden=false] ul li[role=menuitem]"
138
- );
139
- if (params.selfDeclaration.type === "fictional-rendition") {
140
- await selfDeclarationInstance.filter({ hasText: "\u865A\u6784\u6F14\u7ECE\uFF0C\u4EC5\u4F9B\u5A31\u4E50" }).click();
141
- } else if (params.selfDeclaration.type === "ai-generated") {
142
- await selfDeclarationInstance.filter({ hasText: "\u7B14\u8BB0\u542BAI\u5408\u6210\u5185\u5BB9" }).click();
143
- } else if (params.selfDeclaration.type === "source-statement") {
144
- await selfDeclarationInstance.filter({ hasText: "\u5185\u5BB9\u6765\u6E90\u58F0\u660E" }).click();
145
- const selfDeclarationSecondaryMenuInstance = page.locator(".el-popper[aria-hidden=false] .el-cascader-menu").nth(1).locator("ul li[role=menuitem]");
146
- await selfDeclarationSecondaryMenuInstance.first().waitFor();
147
- if (params.selfDeclaration.childType === "self-labeling") {
148
- await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u5DF2\u81EA\u4E3B\u6807\u6CE8" }).click();
149
- } else if (params.selfDeclaration.childType === "self-shooting") {
150
- const { shootingDate, shootingLocation } = params.selfDeclaration;
151
- await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u81EA\u4E3B\u62CD\u6444" }).click();
152
- const selfShootingPopup = page.locator(".el-overlay-dialog[aria-modal=true][role=dialog]").filter({ hasText: "\u81EA\u4E3B\u62CD\u6444" });
153
- await selfShootingPopup.waitFor();
154
- const hasCustomContent = shootingDate || shootingLocation;
155
- if (shootingLocation) {
156
- await selectAddress(
157
- selfShootingPopup.locator(".address-input input"),
158
- shootingLocation
159
- );
160
- }
161
- if (shootingDate) {
162
- await selectDate(
163
- selfShootingPopup.locator(".date-picker input"),
164
- shootingDate
165
- );
166
- }
167
- await selfShootingPopup.locator("footer button").filter({ hasText: hasCustomContent ? "\u786E\u8BA4" : "\u53D6\u6D88" }).click();
168
- } else if (params.selfDeclaration.childType === "transshipment") {
169
- await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u6765\u6E90\u8F6C\u8F7D" }).click();
170
- const selfShootingPopup = page.locator(".el-overlay-dialog[aria-modal=true][role=dialog]").filter({ hasText: "\u6765\u6E90\u5A92\u4F53" });
171
- await selfShootingPopup.waitFor();
172
- const sourceMedia = params.selfDeclaration.sourceMedia;
173
- if (sourceMedia) {
174
- await selfShootingPopup.locator(".el-input input").fill(sourceMedia);
131
+ if (params.address) {
132
+ await selectAddress(
133
+ ".media-extension .address-input input[placeholder=\u6DFB\u52A0\u5730\u70B9]",
134
+ params.address
135
+ );
136
+ }
137
+ if (params.selfDeclaration) {
138
+ await page.locator(".declaration-wrapper").click();
139
+ const selfDeclarationInstance = page.locator(
140
+ ".el-popper[aria-hidden=false] ul li[role=menuitem]"
141
+ );
142
+ if (params.selfDeclaration.type === "fictional-rendition") {
143
+ await selfDeclarationInstance.filter({ hasText: "\u865A\u6784\u6F14\u7ECE\uFF0C\u4EC5\u4F9B\u5A31\u4E50" }).click();
144
+ } else if (params.selfDeclaration.type === "ai-generated") {
145
+ await selfDeclarationInstance.filter({ hasText: "\u7B14\u8BB0\u542BAI\u5408\u6210\u5185\u5BB9" }).click();
146
+ } else if (params.selfDeclaration.type === "source-statement") {
147
+ await selfDeclarationInstance.filter({ hasText: "\u5185\u5BB9\u6765\u6E90\u58F0\u660E" }).click();
148
+ const selfDeclarationSecondaryMenuInstance = page.locator(".el-popper[aria-hidden=false] .el-cascader-menu").nth(1).locator("ul li[role=menuitem]");
149
+ await selfDeclarationSecondaryMenuInstance.first().waitFor();
150
+ if (params.selfDeclaration.childType === "self-labeling") {
151
+ await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u5DF2\u81EA\u4E3B\u6807\u6CE8" }).click();
152
+ } else if (params.selfDeclaration.childType === "self-shooting") {
153
+ const { shootingDate, shootingLocation } = params.selfDeclaration;
154
+ await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u81EA\u4E3B\u62CD\u6444" }).click();
155
+ const selfShootingPopup = page.locator(".el-overlay-dialog[aria-modal=true][role=dialog]").filter({ hasText: "\u81EA\u4E3B\u62CD\u6444" });
156
+ await selfShootingPopup.waitFor();
157
+ const hasCustomContent = shootingDate || shootingLocation;
158
+ if (shootingLocation) {
159
+ await selectAddress(
160
+ selfShootingPopup.locator(".address-input input"),
161
+ shootingLocation
162
+ );
163
+ }
164
+ if (shootingDate) {
165
+ await selectDate(
166
+ selfShootingPopup.locator(".date-picker input"),
167
+ shootingDate
168
+ );
169
+ }
170
+ await selfShootingPopup.locator("footer button").filter({ hasText: hasCustomContent ? "\u786E\u8BA4" : "\u53D6\u6D88" }).click();
171
+ } else if (params.selfDeclaration.childType === "transshipment") {
172
+ await selfDeclarationSecondaryMenuInstance.filter({ hasText: "\u6765\u6E90\u8F6C\u8F7D" }).click();
173
+ const selfShootingPopup = page.locator(".el-overlay-dialog[aria-modal=true][role=dialog]").filter({ hasText: "\u6765\u6E90\u5A92\u4F53" });
174
+ await selfShootingPopup.waitFor();
175
+ const sourceMedia = params.selfDeclaration.sourceMedia;
176
+ if (sourceMedia) {
177
+ await selfShootingPopup.locator(".el-input input").fill(sourceMedia);
178
+ }
179
+ await selfShootingPopup.locator("footer button").filter({ hasText: sourceMedia ? "\u786E\u8BA4" : "\u53D6\u6D88" }).click();
175
180
  }
176
- await selfShootingPopup.locator("footer button").filter({ hasText: sourceMedia ? "\u786E\u8BA4" : "\u53D6\u6D88" }).click();
177
181
  }
178
182
  }
179
183
  const publicLabelInstance = page.locator("label").filter({ hasText: visibleRangeTexts[params.visibleRange] });
@@ -342,6 +346,17 @@ class LocalAutomateTask {
342
346
  this.debug = params.debug || false;
343
347
  this.appWhenReady = createElectronApp(params.cachePath);
344
348
  }
349
+ /**
350
+ * 关闭 playwright 启动的 electron 客户端
351
+ * @returns
352
+ */
353
+ async close() {
354
+ const electronApp = await this.appWhenReady;
355
+ return electronApp.close();
356
+ }
357
+ /**
358
+ * 小红书自动化发布
359
+ */
345
360
  async xiaohongshuPublish(params) {
346
361
  const electronApp = await this.appWhenReady;
347
362
  const commonCookies = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iflyrpa/playwright",
3
3
  "type": "module",
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "description": "",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.mjs",