@jackwener/opencli 0.2.0 → 0.3.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.
Files changed (69) hide show
  1. package/CLI-CREATOR.md +51 -72
  2. package/README.md +8 -5
  3. package/README.zh-CN.md +8 -5
  4. package/SKILL.md +27 -14
  5. package/dist/browser.d.ts +6 -0
  6. package/dist/browser.js +65 -1
  7. package/dist/clis/bilibili/dynamic.d.ts +1 -0
  8. package/dist/clis/bilibili/dynamic.js +33 -0
  9. package/dist/clis/bilibili/ranking.d.ts +1 -0
  10. package/dist/clis/bilibili/ranking.js +24 -0
  11. package/dist/clis/reddit/frontpage.yaml +30 -0
  12. package/dist/clis/reddit/hot.yaml +3 -2
  13. package/dist/clis/reddit/search.yaml +34 -0
  14. package/dist/clis/reddit/subreddit.yaml +39 -0
  15. package/dist/clis/twitter/bookmarks.yaml +85 -0
  16. package/dist/clis/twitter/profile.d.ts +1 -0
  17. package/dist/clis/twitter/profile.js +56 -0
  18. package/dist/clis/twitter/search.d.ts +1 -0
  19. package/dist/clis/twitter/search.js +60 -0
  20. package/dist/clis/twitter/timeline.d.ts +1 -0
  21. package/dist/clis/twitter/timeline.js +47 -0
  22. package/dist/clis/xiaohongshu/user.d.ts +1 -0
  23. package/dist/clis/xiaohongshu/user.js +40 -0
  24. package/dist/clis/xueqiu/feed.yaml +53 -0
  25. package/dist/clis/xueqiu/hot-stock.yaml +49 -0
  26. package/dist/clis/xueqiu/hot.yaml +46 -0
  27. package/dist/clis/xueqiu/search.yaml +53 -0
  28. package/dist/clis/xueqiu/stock.yaml +67 -0
  29. package/dist/clis/xueqiu/watchlist.yaml +46 -0
  30. package/dist/clis/zhihu/hot.yaml +6 -2
  31. package/dist/clis/zhihu/search.yaml +3 -1
  32. package/dist/engine.d.ts +1 -1
  33. package/dist/engine.js +9 -1
  34. package/dist/main.d.ts +1 -1
  35. package/dist/main.js +10 -3
  36. package/dist/pipeline/steps/intercept.js +56 -29
  37. package/dist/pipeline/template.js +3 -1
  38. package/dist/pipeline/template.test.js +6 -0
  39. package/dist/types.d.ts +6 -0
  40. package/package.json +1 -1
  41. package/src/browser.ts +72 -4
  42. package/src/clis/bilibili/dynamic.ts +34 -0
  43. package/src/clis/bilibili/ranking.ts +25 -0
  44. package/src/clis/reddit/frontpage.yaml +30 -0
  45. package/src/clis/reddit/hot.yaml +3 -2
  46. package/src/clis/reddit/search.yaml +34 -0
  47. package/src/clis/reddit/subreddit.yaml +39 -0
  48. package/src/clis/twitter/bookmarks.yaml +85 -0
  49. package/src/clis/twitter/profile.ts +61 -0
  50. package/src/clis/twitter/search.ts +65 -0
  51. package/src/clis/twitter/timeline.ts +50 -0
  52. package/src/clis/xiaohongshu/user.ts +45 -0
  53. package/src/clis/xueqiu/feed.yaml +53 -0
  54. package/src/clis/xueqiu/hot-stock.yaml +49 -0
  55. package/src/clis/xueqiu/hot.yaml +46 -0
  56. package/src/clis/xueqiu/search.yaml +53 -0
  57. package/src/clis/xueqiu/stock.yaml +67 -0
  58. package/src/clis/xueqiu/watchlist.yaml +46 -0
  59. package/src/clis/zhihu/hot.yaml +6 -2
  60. package/src/clis/zhihu/search.yaml +3 -1
  61. package/src/engine.ts +10 -1
  62. package/src/main.ts +9 -3
  63. package/src/pipeline/steps/intercept.ts +58 -28
  64. package/src/pipeline/template.test.ts +6 -0
  65. package/src/pipeline/template.ts +3 -1
  66. package/src/types.ts +3 -0
  67. package/dist/clis/index.d.ts +0 -22
  68. package/dist/clis/index.js +0 -34
  69. package/src/clis/index.ts +0 -46
@@ -75,6 +75,12 @@ describe('evalExpr', () => {
75
75
  it('applies length filter', () => {
76
76
  expect(evalExpr('item.items | length', { item: { items: [1, 2, 3] } })).toBe(3);
77
77
  });
78
+ it('applies json filter to strings with quotes', () => {
79
+ expect(evalExpr('args.keyword | json', { args: { keyword: "O'Reilly" } })).toBe('"O\'Reilly"');
80
+ });
81
+ it('applies json filter to nullish values', () => {
82
+ expect(evalExpr('args.keyword | json', { args: {} })).toBe('null');
83
+ });
78
84
  });
79
85
 
80
86
  describe('render', () => {
@@ -75,7 +75,7 @@ export function evalExpr(expr: string, ctx: RenderContext): any {
75
75
  * Apply a named filter to a value.
76
76
  * Supported filters:
77
77
  * default(val), join(sep), upper, lower, truncate(n), trim,
78
- * replace(old,new), keys, length, first, last
78
+ * replace(old,new), keys, length, first, last, json
79
79
  */
80
80
  function applyFilter(filterExpr: string, value: any): any {
81
81
  const match = filterExpr.match(/^(\w+)(?:\((.+)\))?$/);
@@ -117,6 +117,8 @@ function applyFilter(filterExpr: string, value: any): any {
117
117
  return Array.isArray(value) ? value[0] : value;
118
118
  case 'last':
119
119
  return Array.isArray(value) ? value[value.length - 1] : value;
120
+ case 'json':
121
+ return JSON.stringify(value ?? null);
120
122
  default:
121
123
  return value;
122
124
  }
package/src/types.ts CHANGED
@@ -20,4 +20,7 @@ export interface IPage {
20
20
  networkRequests(includeStatic?: boolean): Promise<any>;
21
21
  consoleMessages(level?: string): Promise<any>;
22
22
  scroll(direction?: string, amount?: number): Promise<void>;
23
+ autoScroll(options?: { times?: number; delayMs?: number }): Promise<void>;
24
+ installInterceptor(pattern: string): Promise<void>;
25
+ getInterceptedRequests(): Promise<any[]>;
23
26
  }
@@ -1,22 +0,0 @@
1
- /**
2
- * Import all TypeScript CLI adapters so they self-register.
3
- *
4
- * Each TS adapter calls cli() on import, which adds itself to the global registry.
5
- */
6
- import './bilibili/search.js';
7
- import './bilibili/me.js';
8
- import './bilibili/favorite.js';
9
- import './bilibili/history.js';
10
- import './bilibili/feed.js';
11
- import './bilibili/user-videos.js';
12
- import './github/search.js';
13
- import './zhihu/question.js';
14
- import './xiaohongshu/search.js';
15
- import './bbc/news.js';
16
- import './weibo/hot.js';
17
- import './boss/search.js';
18
- import './yahoo-finance/quote.js';
19
- import './reuters/search.js';
20
- import './smzdm/search.js';
21
- import './ctrip/search.js';
22
- import './youtube/search.js';
@@ -1,34 +0,0 @@
1
- /**
2
- * Import all TypeScript CLI adapters so they self-register.
3
- *
4
- * Each TS adapter calls cli() on import, which adds itself to the global registry.
5
- */
6
- // bilibili
7
- import './bilibili/search.js';
8
- import './bilibili/me.js';
9
- import './bilibili/favorite.js';
10
- import './bilibili/history.js';
11
- import './bilibili/feed.js';
12
- import './bilibili/user-videos.js';
13
- // github
14
- import './github/search.js';
15
- // zhihu
16
- import './zhihu/question.js';
17
- // xiaohongshu
18
- import './xiaohongshu/search.js';
19
- // bbc
20
- import './bbc/news.js';
21
- // weibo
22
- import './weibo/hot.js';
23
- // boss
24
- import './boss/search.js';
25
- // yahoo-finance
26
- import './yahoo-finance/quote.js';
27
- // reuters
28
- import './reuters/search.js';
29
- // smzdm
30
- import './smzdm/search.js';
31
- // ctrip
32
- import './ctrip/search.js';
33
- // youtube
34
- import './youtube/search.js';
package/src/clis/index.ts DELETED
@@ -1,46 +0,0 @@
1
- /**
2
- * Import all TypeScript CLI adapters so they self-register.
3
- *
4
- * Each TS adapter calls cli() on import, which adds itself to the global registry.
5
- */
6
-
7
- // bilibili
8
- import './bilibili/search.js';
9
- import './bilibili/me.js';
10
- import './bilibili/favorite.js';
11
- import './bilibili/history.js';
12
- import './bilibili/feed.js';
13
- import './bilibili/user-videos.js';
14
-
15
- // github
16
- import './github/search.js';
17
-
18
- // zhihu
19
- import './zhihu/question.js';
20
-
21
- // xiaohongshu
22
- import './xiaohongshu/search.js';
23
-
24
- // bbc
25
- import './bbc/news.js';
26
-
27
- // weibo
28
- import './weibo/hot.js';
29
-
30
- // boss
31
- import './boss/search.js';
32
-
33
- // yahoo-finance
34
- import './yahoo-finance/quote.js';
35
-
36
- // reuters
37
- import './reuters/search.js';
38
-
39
- // smzdm
40
- import './smzdm/search.js';
41
-
42
- // ctrip
43
- import './ctrip/search.js';
44
-
45
- // youtube
46
- import './youtube/search.js';