@reventlessdev/reventless-spec 3.0.0-alpha.85 → 3.0.0-alpha.86
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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/generator/PlatformGenerator.res +29 -50
- package/src/generator/PlatformGenerator.res.mjs +30 -56
- package/src/generator/PlatformManifests.res +203 -0
- package/src/generator/PlatformManifests.res.mjs +212 -0
- package/src/semantic/Bytes.res +54 -0
- package/src/semantic/Bytes.res.mjs +38 -0
- package/src/semantic/Color.res +51 -0
- package/src/semantic/Color.res.mjs +29 -0
- package/src/semantic/Duration.res +53 -0
- package/src/semantic/Duration.res.mjs +26 -0
- package/src/semantic/Email.res +51 -0
- package/src/semantic/Email.res.mjs +31 -0
- package/src/semantic/Percent.res +53 -0
- package/src/semantic/Percent.res.mjs +33 -0
- package/src/semantic/Phone.res +55 -0
- package/src/semantic/Phone.res.mjs +29 -0
- package/src/semantic/Semantic.res +34 -0
- package/src/semantic/Semantic.res.mjs +25 -1
- package/src/semantic/Url.res +66 -0
- package/src/semantic/Url.res.mjs +48 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as Semantic$Reventless from "./Semantic.res.mjs";
|
|
5
|
+
|
|
6
|
+
let grammar = S.url(S.string, undefined);
|
|
7
|
+
|
|
8
|
+
function hasWebScheme(raw) {
|
|
9
|
+
let lower = raw.toLowerCase();
|
|
10
|
+
if (lower.startsWith("http://")) {
|
|
11
|
+
return true;
|
|
12
|
+
} else {
|
|
13
|
+
return lower.startsWith("https://");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function fromString(raw) {
|
|
18
|
+
let value;
|
|
19
|
+
try {
|
|
20
|
+
value = S.parseOrThrow(raw, grammar);
|
|
21
|
+
} catch (exn) {
|
|
22
|
+
return {
|
|
23
|
+
TAG: "Error",
|
|
24
|
+
_0: `expected an absolute URL, got ` + Semantic$Reventless.showString(raw) + `. A relative path is not a URL — include the scheme and host.`
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (hasWebScheme(value)) {
|
|
28
|
+
return {
|
|
29
|
+
TAG: "Ok",
|
|
30
|
+
_0: value
|
|
31
|
+
};
|
|
32
|
+
} else {
|
|
33
|
+
return {
|
|
34
|
+
TAG: "Error",
|
|
35
|
+
_0: `a URL field takes an http:// or https:// address, got ` + Semantic$Reventless.showString(raw) + `. Use Email or Phone for mailto:/tel:, and a storage ref for an uploaded object.`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let schema = Semantic$Reventless.refined(S.string, Semantic$Reventless.Id.url, fromString);
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
grammar,
|
|
44
|
+
hasWebScheme,
|
|
45
|
+
fromString,
|
|
46
|
+
schema,
|
|
47
|
+
}
|
|
48
|
+
/* grammar Not a pure module */
|