@qrxcode/js 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.
- package/README.md +95 -21
- package/dist/index.cjs +7 -8
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,9 +29,7 @@ and natural as following someone on social media.
|
|
|
29
29
|
|
|
30
30
|
Examples of flows:
|
|
31
31
|
|
|
32
|
-
-
|
|
33
|
-
- Atom feeds
|
|
34
|
-
- JSON feeds
|
|
32
|
+
- Feed flows
|
|
35
33
|
|
|
36
34
|
In QRX, a "flow" is a recognized machine-readable relationship
|
|
37
35
|
that applications can discover and interact with.
|
|
@@ -42,38 +40,54 @@ QRX helps applications discover and work with them more naturally.
|
|
|
42
40
|
|
|
43
41
|
Learn more at https://qrx.dev
|
|
44
42
|
|
|
45
|
-
## Breaking change in 0.
|
|
43
|
+
## Breaking change in 0.3.0
|
|
46
44
|
|
|
47
|
-
Version `0.
|
|
45
|
+
Version `0.3.0` introduces a breaking cleanup of feed flow classification.
|
|
48
46
|
|
|
49
|
-
Before `0.
|
|
47
|
+
Before `0.3.0`, RSS, Atom, and JSON Feed were represented as separate
|
|
48
|
+
QRX flow types:
|
|
50
49
|
|
|
51
50
|
```js
|
|
52
51
|
{
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
flowType: "rss",
|
|
53
|
+
rel: "alternate",
|
|
54
|
+
href: "https://example.com/feed.xml",
|
|
55
|
+
type: "application/rss+xml"
|
|
55
56
|
}
|
|
56
57
|
````
|
|
57
58
|
|
|
58
|
-
Starting from `0.
|
|
59
|
+
Starting from `0.3.0`, RSS, Atom, and JSON Feed are represented as the same
|
|
60
|
+
QRX flow category:
|
|
59
61
|
|
|
60
62
|
```js
|
|
61
63
|
{
|
|
62
|
-
flowType: "
|
|
64
|
+
flowType: "feed",
|
|
63
65
|
rel: "alternate",
|
|
64
66
|
href: "https://example.com/feed.xml",
|
|
65
67
|
type: "application/rss+xml"
|
|
66
68
|
}
|
|
67
69
|
```
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
The actual feed format remains in the original HTML/link media type:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
type: "application/rss+xml"
|
|
75
|
+
type: "application/atom+xml"
|
|
76
|
+
type: "application/feed+json"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Core formula:
|
|
80
|
+
|
|
81
|
+
```txt
|
|
82
|
+
flowType = QRX category
|
|
83
|
+
type = original web/media format
|
|
84
|
+
```
|
|
70
85
|
|
|
71
|
-
|
|
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`.
|
|
86
|
+
Migration:
|
|
75
87
|
|
|
76
|
-
|
|
88
|
+
* `flow.flowType === "rss"` is now `flow.flowType === "feed" && flow.type === "application/rss+xml"`.
|
|
89
|
+
* `flow.flowType === "atom"` is now `flow.flowType === "feed" && flow.type === "application/atom+xml"`.
|
|
90
|
+
* `flow.flowType === "jsonfeed"` is now `flow.flowType === "feed" && flow.type === "application/feed+json"`.
|
|
77
91
|
|
|
78
92
|
QRX discovers recognized flows. Applications decide what to do with them.
|
|
79
93
|
|
|
@@ -100,13 +114,13 @@ console.log(result.flows);
|
|
|
100
114
|
```js
|
|
101
115
|
[
|
|
102
116
|
{
|
|
103
|
-
flowType: "
|
|
117
|
+
flowType: "feed",
|
|
104
118
|
rel: "alternate",
|
|
105
119
|
href: "https://podnews.net/rss",
|
|
106
120
|
type: "application/rss+xml"
|
|
107
121
|
},
|
|
108
122
|
{
|
|
109
|
-
flowType: "
|
|
123
|
+
flowType: "feed",
|
|
110
124
|
rel: "alternate",
|
|
111
125
|
href: "https://podnews.net/feed.json",
|
|
112
126
|
type: "application/feed+json"
|
|
@@ -114,11 +128,67 @@ console.log(result.flows);
|
|
|
114
128
|
]
|
|
115
129
|
```
|
|
116
130
|
|
|
131
|
+
## Selecting flows
|
|
132
|
+
|
|
133
|
+
To select all feed flows:
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
import {
|
|
137
|
+
resolveQRX,
|
|
138
|
+
selectFlowsByFlowType
|
|
139
|
+
} from "@qrxcode/js";
|
|
140
|
+
|
|
141
|
+
const result = await resolveQRX(
|
|
142
|
+
"https://podnews.net"
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const feeds = selectFlowsByFlowType(
|
|
146
|
+
result.flows,
|
|
147
|
+
["feed"]
|
|
148
|
+
);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
This returns RSS, Atom, and JSON Feed flows together.
|
|
152
|
+
|
|
153
|
+
To select only RSS feeds, filter by the original media type:
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
const rssFeeds = result.flows.filter(
|
|
157
|
+
(discoveredFlow) =>
|
|
158
|
+
discoveredFlow.flowType === "feed" &&
|
|
159
|
+
discoveredFlow.type === "application/rss+xml"
|
|
160
|
+
);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
To select only Atom feeds:
|
|
164
|
+
|
|
165
|
+
```js
|
|
166
|
+
const atomFeeds = result.flows.filter(
|
|
167
|
+
(discoveredFlow) =>
|
|
168
|
+
discoveredFlow.flowType === "feed" &&
|
|
169
|
+
discoveredFlow.type === "application/atom+xml"
|
|
170
|
+
);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
To select only JSON Feed feeds:
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
const jsonFeeds = result.flows.filter(
|
|
177
|
+
(discoveredFlow) =>
|
|
178
|
+
discoveredFlow.flowType === "feed" &&
|
|
179
|
+
discoveredFlow.type === "application/feed+json"
|
|
180
|
+
);
|
|
181
|
+
```
|
|
182
|
+
|
|
117
183
|
## Supported flow types
|
|
118
184
|
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
185
|
+
* feed
|
|
186
|
+
|
|
187
|
+
## Supported feed formats
|
|
188
|
+
|
|
189
|
+
* RSS: `application/rss+xml`
|
|
190
|
+
* Atom: `application/atom+xml`
|
|
191
|
+
* JSON Feed: `application/feed+json`
|
|
122
192
|
|
|
123
193
|
## Supported discovery methods
|
|
124
194
|
|
|
@@ -147,5 +217,9 @@ console.log(result.flows);
|
|
|
147
217
|
|
|
148
218
|
QRX does not change QR codes.
|
|
149
219
|
|
|
220
|
+
QRX discovers recognized flows.
|
|
221
|
+
|
|
222
|
+
Applications decide what to do with them.
|
|
223
|
+
|
|
150
224
|
With QRX, sources can expose machine-readable flows,
|
|
151
225
|
and applications can understand and interact with them naturally.
|
package/dist/index.cjs
CHANGED
|
@@ -27,11 +27,11 @@ __export(index_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
29
|
// src/detect.ts
|
|
30
|
-
var
|
|
31
|
-
"application/rss+xml"
|
|
32
|
-
"application/atom+xml"
|
|
33
|
-
"application/feed+json"
|
|
34
|
-
|
|
30
|
+
var FEED_TYPES = /* @__PURE__ */ new Set([
|
|
31
|
+
"application/rss+xml",
|
|
32
|
+
"application/atom+xml",
|
|
33
|
+
"application/feed+json"
|
|
34
|
+
]);
|
|
35
35
|
function detectFlows(html, sourceUrl) {
|
|
36
36
|
const flows = [];
|
|
37
37
|
const linkTagRegex = /<link\s+[^>]*>/gi;
|
|
@@ -48,12 +48,11 @@ function detectFlows(html, sourceUrl) {
|
|
|
48
48
|
if (!hasRel(normalizedRel, "alternate")) {
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
if (!flowType) {
|
|
51
|
+
if (!FEED_TYPES.has(normalizedType)) {
|
|
53
52
|
continue;
|
|
54
53
|
}
|
|
55
54
|
flows.push({
|
|
56
|
-
flowType,
|
|
55
|
+
flowType: "feed",
|
|
57
56
|
rel: normalizedRel,
|
|
58
57
|
href: new URL(href, sourceUrl).toString(),
|
|
59
58
|
type: normalizedType
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/detect.ts
|
|
2
|
-
var
|
|
3
|
-
"application/rss+xml"
|
|
4
|
-
"application/atom+xml"
|
|
5
|
-
"application/feed+json"
|
|
6
|
-
|
|
2
|
+
var FEED_TYPES = /* @__PURE__ */ new Set([
|
|
3
|
+
"application/rss+xml",
|
|
4
|
+
"application/atom+xml",
|
|
5
|
+
"application/feed+json"
|
|
6
|
+
]);
|
|
7
7
|
function detectFlows(html, sourceUrl) {
|
|
8
8
|
const flows = [];
|
|
9
9
|
const linkTagRegex = /<link\s+[^>]*>/gi;
|
|
@@ -20,12 +20,11 @@ function detectFlows(html, sourceUrl) {
|
|
|
20
20
|
if (!hasRel(normalizedRel, "alternate")) {
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
if (!flowType) {
|
|
23
|
+
if (!FEED_TYPES.has(normalizedType)) {
|
|
25
24
|
continue;
|
|
26
25
|
}
|
|
27
26
|
flows.push({
|
|
28
|
-
flowType,
|
|
27
|
+
flowType: "feed",
|
|
29
28
|
rel: normalizedRel,
|
|
30
29
|
href: new URL(href, sourceUrl).toString(),
|
|
31
30
|
type: normalizedType
|