@dion-js/extension-test-utils 0.2.0 → 0.2.1

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 (2) hide show
  1. package/package.json +6 -6
  2. package/src/main.ts +10 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dion-js/extension-test-utils",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/main.ts"
@@ -9,13 +9,13 @@
9
9
  "image-url-validator": "^1.0.4",
10
10
  "m3u8-parser": "^7.2.0",
11
11
  "node-fetch": "^3.3.2",
12
- "@dion-js/extension-types": "0.4.0",
13
- "@dion-js/runtime-types": "0.4.0"
12
+ "@dion-js/extension-types": "workspace:*",
13
+ "@dion-js/runtime-types": "workspace:*"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/m3u8-parser": "^7.2.2",
17
- "@dion-js/config": "0.1.0",
18
- "@dion-js/extension-types": "0.4.0",
19
- "@types/bun": "1.3.3"
17
+ "@dion-js/config": "workspace:*",
18
+ "@dion-js/extension-types": "workspace:*",
19
+ "@types/bun": "catalog:"
20
20
  }
21
21
  }
package/src/main.ts CHANGED
@@ -102,6 +102,10 @@ function assert(condition: boolean, message: string): asserts condition {
102
102
  if (!condition) throw new Error(message);
103
103
  }
104
104
 
105
+ function assertWarn(condition: boolean, message: string): asserts condition {
106
+ if (!condition) console.warn(message);
107
+ }
108
+
105
109
  export async function assertValidM3U8(
106
110
  link: Link,
107
111
  options?: {
@@ -111,7 +115,7 @@ export async function assertValidM3U8(
111
115
  console.log(`Checking ${link.url}`);
112
116
  await ratelimit(time);
113
117
  const response = await fetch(link.url, { headers: link.header ?? undefined });
114
- assert(
118
+ assertWarn(
115
119
  response.ok,
116
120
  `${options?.assertmsg} ${link.url} is not a valid url or not reachable`,
117
121
  );
@@ -120,9 +124,9 @@ export async function assertValidM3U8(
120
124
  });
121
125
  parser.push(await response.text());
122
126
  parser.end();
123
- assert(
127
+ assertWarn(
124
128
  parser.manifest.segments.length > 0,
125
- `${options} ${link.url} is not a valid m3u8 url`,
129
+ `${options?.assertmsg} ${link.url} is not a valid m3u8 url`,
126
130
  );
127
131
  }
128
132
 
@@ -134,11 +138,11 @@ export async function assertValidImageURL(
134
138
  ) {
135
139
  await ratelimit(time);
136
140
  const response = await fetch(link.url, { headers: link.header ?? undefined });
137
- assert(
141
+ assertWarn(
138
142
  response.ok,
139
143
  `${options?.assertmsg} ${link.url} is not a valid url or not reachable`,
140
144
  );
141
- assert(
145
+ assertWarn(
142
146
  response.headers
143
147
  .get("content-type")
144
148
  ?.toLocaleLowerCase()
@@ -155,7 +159,7 @@ export async function assertValidURL(
155
159
  ) {
156
160
  await ratelimit(time);
157
161
  const response = await fetch(link.url, { headers: link.header ?? undefined });
158
- assert(
162
+ assertWarn(
159
163
  response.ok,
160
164
  `${options?.assertmsg} ${link.url} is not a valid url or not reachable`,
161
165
  );