@qrxcode/js 0.1.1 → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yeldar Kudaibergen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # QRX flow discovery SDK for JavaScript
2
2
 
3
- Detect RSS, Atom and JSON Feed flows from normal website and page URLs.
3
+ Detect machine-readable flows from normal website and page URLs.
4
4
 
5
5
  With QRX, applications with QR scanners can interact with QR codes
6
6
  more like browsers interact with links.
@@ -33,8 +33,8 @@ Examples of flows:
33
33
  - Atom feeds
34
34
  - JSON feeds
35
35
 
36
- At the moment, "flow" is a broad term used by QRX
37
- to describe machine-readable update streams and feeds.
36
+ In QRX, a "flow" is a recognized machine-readable relationship
37
+ that applications can discover and interact with.
38
38
 
39
39
  QRX does not replace RSS or existing feed technologies.
40
40
 
@@ -42,6 +42,41 @@ QRX helps applications discover and work with them more naturally.
42
42
 
43
43
  Learn more at https://qrx.dev
44
44
 
45
+ ## Breaking change in 0.2.0
46
+
47
+ Version `0.2.0` introduces a breaking cleanup of the flow output model.
48
+
49
+ Before `0.2.0`, flow objects looked like this:
50
+
51
+ ```js
52
+ {
53
+ type: "rss",
54
+ url: "https://example.com/feed.xml"
55
+ }
56
+ ````
57
+
58
+ Starting from `0.2.0`, flow objects look like this:
59
+
60
+ ```js
61
+ {
62
+ flowType: "rss",
63
+ rel: "alternate",
64
+ href: "https://example.com/feed.xml",
65
+ type: "application/rss+xml"
66
+ }
67
+ ```
68
+
69
+ Migration:
70
+
71
+ * `flow.type` used to mean QRX flow classification.
72
+ * QRX flow classification is now `flow.flowType`.
73
+ * `flow.type` now means the original HTML/link media type.
74
+ * `flow.url` is now `flow.href`.
75
+
76
+ QRX now separates QRX flow classification from original web metadata.
77
+
78
+ QRX discovers recognized flows. Applications decide what to do with them.
79
+
45
80
  ## Install
46
81
 
47
82
  ```bash
@@ -65,12 +100,16 @@ console.log(result.flows);
65
100
  ```js
66
101
  [
67
102
  {
68
- type: "rss",
69
- url: "https://podnews.net/rss"
103
+ flowType: "rss",
104
+ rel: "alternate",
105
+ href: "https://podnews.net/rss",
106
+ type: "application/rss+xml"
70
107
  },
71
108
  {
72
- type: "jsonfeed",
73
- url: "https://podnews.net/feed.json"
109
+ flowType: "jsonfeed",
110
+ rel: "alternate",
111
+ href: "https://podnews.net/feed.json",
112
+ type: "application/feed+json"
74
113
  }
75
114
  ]
76
115
  ```
@@ -110,4 +149,3 @@ QRX does not change QR codes.
110
149
 
111
150
  With QRX, sources can expose machine-readable flows,
112
151
  and applications can understand and interact with them naturally.
113
-
package/dist/index.cjs CHANGED
@@ -22,7 +22,7 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  detectFlows: () => detectFlows,
24
24
  resolveQRX: () => resolveQRX,
25
- selectFlows: () => selectFlows
25
+ selectFlowsByFlowType: () => selectFlowsByFlowType
26
26
  });
27
27
  module.exports = __toCommonJS(index_exports);
28
28
 
@@ -40,54 +40,63 @@ function detectFlows(html, sourceUrl) {
40
40
  const rel = getAttribute(tag, "rel");
41
41
  const type = getAttribute(tag, "type");
42
42
  const href = getAttribute(tag, "href");
43
- if (!rel || !type || !href) continue;
44
- if (!rel.includes("alternate")) continue;
45
- const flowType = FLOW_TYPES[type];
46
- if (!flowType) continue;
43
+ if (!rel || !type || !href) {
44
+ continue;
45
+ }
46
+ const normalizedRel = rel.trim();
47
+ const normalizedType = type.trim().toLowerCase();
48
+ if (!hasRel(normalizedRel, "alternate")) {
49
+ continue;
50
+ }
51
+ const flowType = FLOW_TYPES[normalizedType];
52
+ if (!flowType) {
53
+ continue;
54
+ }
47
55
  flows.push({
48
- type: flowType,
49
- url: new URL(href, sourceUrl).toString()
56
+ flowType,
57
+ rel: normalizedRel,
58
+ href: new URL(href, sourceUrl).toString(),
59
+ type: normalizedType
50
60
  });
51
61
  }
52
- return dedupeFlows(flows);
62
+ return flows;
53
63
  }
54
64
  function getAttribute(tag, attribute) {
55
65
  const regex = new RegExp(
56
- `${attribute}=["']([^"']+)["']`,
66
+ `${attribute}\\s*=\\s*["']([^"']+)["']`,
57
67
  "i"
58
68
  );
59
69
  const match = tag.match(regex);
60
70
  return match ? match[1] : null;
61
71
  }
62
- function dedupeFlows(flows) {
63
- const seen = /* @__PURE__ */ new Set();
64
- return flows.filter((flow) => {
65
- const key = `${flow.type}:${flow.url}`;
66
- if (seen.has(key)) return false;
67
- seen.add(key);
68
- return true;
69
- });
72
+ function hasRel(rel, expected) {
73
+ return rel.toLowerCase().split(/\s+/).includes(expected);
70
74
  }
71
75
 
72
76
  // src/resolve.ts
73
77
  async function resolveQRX(url) {
74
78
  const response = await fetch(url);
75
79
  const html = await response.text();
76
- const flows = detectFlows(html, response.url);
80
+ const flows = detectFlows(
81
+ html,
82
+ response.url
83
+ );
77
84
  return {
78
85
  flows
79
86
  };
80
87
  }
81
88
 
82
89
  // src/select.ts
83
- function selectFlows(flows, preferredTypes) {
90
+ function selectFlowsByFlowType(flows, preferredFlowTypes) {
84
91
  return flows.filter(
85
- (flow) => preferredTypes.includes(flow.type)
92
+ (flow) => preferredFlowTypes.includes(
93
+ flow.flowType
94
+ )
86
95
  );
87
96
  }
88
97
  // Annotate the CommonJS export names for ESM import in node:
89
98
  0 && (module.exports = {
90
99
  detectFlows,
91
100
  resolveQRX,
92
- selectFlows
101
+ selectFlowsByFlowType
93
102
  });
package/dist/index.d.cts CHANGED
@@ -1,7 +1,9 @@
1
1
  type FlowType = "rss" | "atom" | "jsonfeed";
2
2
  interface Flow {
3
- type: FlowType;
4
- url: string;
3
+ flowType: FlowType;
4
+ rel: string;
5
+ href: string;
6
+ type: string;
5
7
  }
6
8
  interface QRXResult {
7
9
  flows: Flow[];
@@ -11,6 +13,6 @@ declare function detectFlows(html: string, sourceUrl: string): Flow[];
11
13
 
12
14
  declare function resolveQRX(url: string): Promise<QRXResult>;
13
15
 
14
- declare function selectFlows(flows: Flow[], preferredTypes: FlowType[]): Flow[];
16
+ declare function selectFlowsByFlowType(flows: Flow[], preferredFlowTypes: FlowType[]): Flow[];
15
17
 
16
- export { type Flow, type FlowType, type QRXResult, detectFlows, resolveQRX, selectFlows };
18
+ export { type Flow, type FlowType, type QRXResult, detectFlows, resolveQRX, selectFlowsByFlowType };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  type FlowType = "rss" | "atom" | "jsonfeed";
2
2
  interface Flow {
3
- type: FlowType;
4
- url: string;
3
+ flowType: FlowType;
4
+ rel: string;
5
+ href: string;
6
+ type: string;
5
7
  }
6
8
  interface QRXResult {
7
9
  flows: Flow[];
@@ -11,6 +13,6 @@ declare function detectFlows(html: string, sourceUrl: string): Flow[];
11
13
 
12
14
  declare function resolveQRX(url: string): Promise<QRXResult>;
13
15
 
14
- declare function selectFlows(flows: Flow[], preferredTypes: FlowType[]): Flow[];
16
+ declare function selectFlowsByFlowType(flows: Flow[], preferredFlowTypes: FlowType[]): Flow[];
15
17
 
16
- export { type Flow, type FlowType, type QRXResult, detectFlows, resolveQRX, selectFlows };
18
+ export { type Flow, type FlowType, type QRXResult, detectFlows, resolveQRX, selectFlowsByFlowType };
package/dist/index.js CHANGED
@@ -12,53 +12,62 @@ function detectFlows(html, sourceUrl) {
12
12
  const rel = getAttribute(tag, "rel");
13
13
  const type = getAttribute(tag, "type");
14
14
  const href = getAttribute(tag, "href");
15
- if (!rel || !type || !href) continue;
16
- if (!rel.includes("alternate")) continue;
17
- const flowType = FLOW_TYPES[type];
18
- if (!flowType) continue;
15
+ if (!rel || !type || !href) {
16
+ continue;
17
+ }
18
+ const normalizedRel = rel.trim();
19
+ const normalizedType = type.trim().toLowerCase();
20
+ if (!hasRel(normalizedRel, "alternate")) {
21
+ continue;
22
+ }
23
+ const flowType = FLOW_TYPES[normalizedType];
24
+ if (!flowType) {
25
+ continue;
26
+ }
19
27
  flows.push({
20
- type: flowType,
21
- url: new URL(href, sourceUrl).toString()
28
+ flowType,
29
+ rel: normalizedRel,
30
+ href: new URL(href, sourceUrl).toString(),
31
+ type: normalizedType
22
32
  });
23
33
  }
24
- return dedupeFlows(flows);
34
+ return flows;
25
35
  }
26
36
  function getAttribute(tag, attribute) {
27
37
  const regex = new RegExp(
28
- `${attribute}=["']([^"']+)["']`,
38
+ `${attribute}\\s*=\\s*["']([^"']+)["']`,
29
39
  "i"
30
40
  );
31
41
  const match = tag.match(regex);
32
42
  return match ? match[1] : null;
33
43
  }
34
- function dedupeFlows(flows) {
35
- const seen = /* @__PURE__ */ new Set();
36
- return flows.filter((flow) => {
37
- const key = `${flow.type}:${flow.url}`;
38
- if (seen.has(key)) return false;
39
- seen.add(key);
40
- return true;
41
- });
44
+ function hasRel(rel, expected) {
45
+ return rel.toLowerCase().split(/\s+/).includes(expected);
42
46
  }
43
47
 
44
48
  // src/resolve.ts
45
49
  async function resolveQRX(url) {
46
50
  const response = await fetch(url);
47
51
  const html = await response.text();
48
- const flows = detectFlows(html, response.url);
52
+ const flows = detectFlows(
53
+ html,
54
+ response.url
55
+ );
49
56
  return {
50
57
  flows
51
58
  };
52
59
  }
53
60
 
54
61
  // src/select.ts
55
- function selectFlows(flows, preferredTypes) {
62
+ function selectFlowsByFlowType(flows, preferredFlowTypes) {
56
63
  return flows.filter(
57
- (flow) => preferredTypes.includes(flow.type)
64
+ (flow) => preferredFlowTypes.includes(
65
+ flow.flowType
66
+ )
58
67
  );
59
68
  }
60
69
  export {
61
70
  detectFlows,
62
71
  resolveQRX,
63
- selectFlows
72
+ selectFlowsByFlowType
64
73
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrxcode/js",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "QRX flow discovery SDK for JavaScript.",
5
5
  "homepage": "https://qrx.dev",
6
6
  "repository": {
@@ -21,7 +21,11 @@
21
21
  "require": "./dist/index.cjs"
22
22
  }
23
23
  },
24
- "files": ["dist", "README.md"],
24
+ "files": [
25
+ "dist",
26
+ "README.md",
27
+ "LICENSE"
28
+ ],
25
29
  "scripts": {
26
30
  "build": "tsup src/index.ts --format esm,cjs --dts",
27
31
  "test": "vitest run",