@adviser/cement 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WebSysAbstraction
3
- } from "./chunk-BEOYQN5I.js";
3
+ } from "./chunk-XJF7FQUN.js";
4
4
  import {
5
5
  BrowserEnvActions,
6
6
  EnvImpl,
@@ -17,7 +17,7 @@ import {
17
17
  TimeMode,
18
18
  TimeUnits,
19
19
  envFactory
20
- } from "./chunk-LK3TUJH3.js";
20
+ } from "./chunk-O4F5AURC.js";
21
21
  import {
22
22
  __spreadValues,
23
23
  __yieldStar
@@ -104,6 +104,186 @@ function IsLogger(obj) {
104
104
  ].map((fn) => typeof obj[fn] === "function").reduce((a, b) => a && b, true);
105
105
  }
106
106
 
107
+ // src/uri.ts
108
+ function falsy2undef(value) {
109
+ return value === void 0 || value === null ? void 0 : value;
110
+ }
111
+ function ensureURLWithDefaultProto(url, defaultProtocol) {
112
+ if (!url) {
113
+ return new URL(`${defaultProtocol}//`);
114
+ }
115
+ if (typeof url === "string") {
116
+ try {
117
+ return new URL(url);
118
+ } catch (e) {
119
+ return new URL(`${defaultProtocol}//${url}`);
120
+ }
121
+ } else {
122
+ return url;
123
+ }
124
+ }
125
+ function isURL(value) {
126
+ return value instanceof URL || !!value && typeof value.searchParams === "object" && typeof value.searchParams.sort === "function" && typeof value.hash === "string";
127
+ }
128
+ function from(fac, strURLUri, defaultProtocol) {
129
+ switch (typeof falsy2undef(strURLUri)) {
130
+ case "undefined":
131
+ return fac(new URL(`${defaultProtocol}//`));
132
+ case "string":
133
+ return fac(ensureURLWithDefaultProto(strURLUri, defaultProtocol));
134
+ case "object":
135
+ if (BuildURI.is(strURLUri)) {
136
+ return fac(new URL(strURLUri._url.toString()));
137
+ } else if (URI.is(strURLUri)) {
138
+ return fac(new URL(strURLUri._url.toString()));
139
+ } else if (isURL(strURLUri)) {
140
+ return fac(new URL(strURLUri.toString()));
141
+ }
142
+ throw new Error(`unknown object type: ${strURLUri}`);
143
+ default:
144
+ throw new Error(`Invalid argument: ${typeof strURLUri}`);
145
+ }
146
+ }
147
+ var BuildURI = class _BuildURI {
148
+ constructor(url) {
149
+ this._url = url;
150
+ }
151
+ static is(value) {
152
+ return value instanceof _BuildURI || !!value && typeof value.delParam === "function" && typeof value.setParam === "function";
153
+ }
154
+ static from(strURLUri, defaultProtocol = "file:") {
155
+ return from((url) => new _BuildURI(url), strURLUri, defaultProtocol);
156
+ }
157
+ hostname(h) {
158
+ this._url.hostname = h;
159
+ return this;
160
+ }
161
+ password(p) {
162
+ this._url.password = p;
163
+ return this;
164
+ }
165
+ port(p) {
166
+ this._url.port = p;
167
+ return this;
168
+ }
169
+ username(u) {
170
+ this._url.username = u;
171
+ return this;
172
+ }
173
+ search(s) {
174
+ this._url.search = s;
175
+ return this;
176
+ }
177
+ protocol(p) {
178
+ this._url.protocol = p;
179
+ return this;
180
+ }
181
+ pathname(p) {
182
+ this._url.pathname = p;
183
+ return this;
184
+ }
185
+ hash(h) {
186
+ this._url.hash = h;
187
+ return this;
188
+ }
189
+ host(h) {
190
+ this._url.host = h;
191
+ return this;
192
+ }
193
+ delParam(key) {
194
+ this._url.searchParams.delete(key);
195
+ return this;
196
+ }
197
+ defParam(key, str) {
198
+ if (!this._url.searchParams.has(key)) {
199
+ this._url.searchParams.set(key, str);
200
+ }
201
+ return this;
202
+ }
203
+ setParam(key, str) {
204
+ this._url.searchParams.set(key, str);
205
+ return this;
206
+ }
207
+ toString() {
208
+ this._url.searchParams.sort();
209
+ return this._url.toString();
210
+ }
211
+ URI() {
212
+ return URI.from(this._url);
213
+ }
214
+ };
215
+ var URI = class _URI {
216
+ // if no protocol is provided, default to file:
217
+ static merge(into, from2, defaultProtocol = "file:") {
218
+ const intoUrl = _URI.from(into, defaultProtocol);
219
+ const fromUrl = _URI.from(from2, defaultProtocol);
220
+ for (const [key, value] of fromUrl._url.searchParams) {
221
+ if (!intoUrl._url.searchParams.has(key)) {
222
+ intoUrl._url.searchParams.set(key, value);
223
+ }
224
+ }
225
+ return intoUrl;
226
+ }
227
+ static is(value) {
228
+ return value instanceof _URI || !!value && typeof value.asURL === "function" && typeof value.getParam === "function" && typeof value.hasParam === "function";
229
+ }
230
+ // if no protocol is provided, default to file:
231
+ static from(strURLUri, defaultProtocol = "file:") {
232
+ return from((url) => new _URI(url), strURLUri, defaultProtocol);
233
+ }
234
+ constructor(url) {
235
+ this._url = url;
236
+ }
237
+ build() {
238
+ return BuildURI.from(this.asURL());
239
+ }
240
+ get hostname() {
241
+ return this._url.hostname;
242
+ }
243
+ get password() {
244
+ return this._url.password;
245
+ }
246
+ get port() {
247
+ return this._url.port;
248
+ }
249
+ get username() {
250
+ return this._url.username;
251
+ }
252
+ get search() {
253
+ return this._url.search;
254
+ }
255
+ get protocol() {
256
+ return this._url.protocol;
257
+ }
258
+ get pathname() {
259
+ return this._url.toString().replace(/^.*:\/\//, "").replace(/\?.*$/, "");
260
+ }
261
+ get hash() {
262
+ return this._url.hash;
263
+ }
264
+ get host() {
265
+ return this._url.host;
266
+ }
267
+ hasParam(key) {
268
+ return this._url.searchParams.has(key);
269
+ }
270
+ getParam(key) {
271
+ return falsy2undef(this._url.searchParams.get(key));
272
+ }
273
+ clone() {
274
+ return new _URI(this.asURL());
275
+ }
276
+ asURL() {
277
+ const url = new URL(this._url.toString());
278
+ url.searchParams.sort();
279
+ return url;
280
+ }
281
+ toString() {
282
+ this._url.searchParams.sort();
283
+ return this._url.toString();
284
+ }
285
+ };
286
+
107
287
  // src/logger_impl.ts
108
288
  var encoder = new TextEncoder();
109
289
  var LevelHandlerImpl = class {
@@ -361,7 +541,7 @@ var LoggerImpl = class _LoggerImpl {
361
541
  return this;
362
542
  }
363
543
  Url(url, key = "url") {
364
- this.Ref(key, () => url.toString());
544
+ this.Ref(key, () => URI.from(url).toString());
365
545
  return this;
366
546
  }
367
547
  Str(key, value) {
@@ -775,196 +955,17 @@ function isSet(value, ref = globalThis) {
775
955
  return false;
776
956
  }
777
957
  function runtimeFn() {
778
- const isNodeIsh = isSet("process.versions.node");
779
- const isDeno = isSet("Deno");
958
+ const isReactNative = isSet("navigator.product") && globalThis.navigator.product === "ReactNative";
959
+ const isNodeIsh = isSet("process.versions.node") && !isReactNative;
960
+ const isDeno = isSet("Deno") && !isReactNative;
780
961
  return {
781
962
  isNodeIsh,
782
- isBrowser: !(isNodeIsh || isDeno),
963
+ isBrowser: !(isNodeIsh || isDeno) && !isReactNative,
783
964
  isDeno,
784
- isReactNative: false
965
+ isReactNative
785
966
  };
786
967
  }
787
968
 
788
- // src/uri.ts
789
- function falsy2undef(value) {
790
- return value === void 0 || value === null ? void 0 : value;
791
- }
792
- function ensureURLWithDefaultProto(url, defaultProtocol) {
793
- if (!url) {
794
- return new URL(`${defaultProtocol}//`);
795
- }
796
- if (typeof url === "string") {
797
- try {
798
- return new URL(url);
799
- } catch (e) {
800
- return new URL(`${defaultProtocol}//${url}`);
801
- }
802
- } else {
803
- return url;
804
- }
805
- }
806
- function isURL(value) {
807
- return value instanceof URL || !!value && typeof value.searchParams === "object" && typeof value.searchParams.sort === "function" && typeof value.hash === "string";
808
- }
809
- function from(fac, strURLUri, defaultProtocol) {
810
- switch (typeof falsy2undef(strURLUri)) {
811
- case "undefined":
812
- return fac(new URL(`${defaultProtocol}//`));
813
- case "string":
814
- return fac(ensureURLWithDefaultProto(strURLUri, defaultProtocol));
815
- case "object":
816
- if (BuildURI.is(strURLUri)) {
817
- return fac(new URL(strURLUri._url.toString()));
818
- } else if (URI.is(strURLUri)) {
819
- return fac(new URL(strURLUri._url.toString()));
820
- } else if (isURL(strURLUri)) {
821
- return fac(new URL(strURLUri.toString()));
822
- }
823
- throw new Error(`unknown object type: ${strURLUri}`);
824
- default:
825
- throw new Error(`Invalid argument: ${typeof strURLUri}`);
826
- }
827
- }
828
- var BuildURI = class _BuildURI {
829
- constructor(url) {
830
- this._url = url;
831
- }
832
- static is(value) {
833
- return value instanceof _BuildURI || !!value && typeof value.delParam === "function" && typeof value.setParam === "function";
834
- }
835
- static from(strURLUri, defaultProtocol = "file:") {
836
- return from((url) => new _BuildURI(url), strURLUri, defaultProtocol);
837
- }
838
- hostname(h) {
839
- this._url.hostname = h;
840
- return this;
841
- }
842
- password(p) {
843
- this._url.password = p;
844
- return this;
845
- }
846
- port(p) {
847
- this._url.port = p;
848
- return this;
849
- }
850
- username(u) {
851
- this._url.username = u;
852
- return this;
853
- }
854
- search(s) {
855
- this._url.search = s;
856
- return this;
857
- }
858
- protocol(p) {
859
- this._url.protocol = p;
860
- return this;
861
- }
862
- pathname(p) {
863
- this._url.pathname = p;
864
- return this;
865
- }
866
- hash(h) {
867
- this._url.hash = h;
868
- return this;
869
- }
870
- host(h) {
871
- this._url.host = h;
872
- return this;
873
- }
874
- delParam(key) {
875
- this._url.searchParams.delete(key);
876
- return this;
877
- }
878
- defParam(key, str) {
879
- if (!this._url.searchParams.has(key)) {
880
- this._url.searchParams.set(key, str);
881
- }
882
- return this;
883
- }
884
- setParam(key, str) {
885
- this._url.searchParams.set(key, str);
886
- return this;
887
- }
888
- toString() {
889
- this._url.searchParams.sort();
890
- return this._url.toString();
891
- }
892
- URI() {
893
- return URI.from(this._url);
894
- }
895
- };
896
- var URI = class _URI {
897
- // if no protocol is provided, default to file:
898
- static merge(into, from2, defaultProtocol = "file:") {
899
- const intoUrl = _URI.from(into, defaultProtocol);
900
- const fromUrl = _URI.from(from2, defaultProtocol);
901
- for (const [key, value] of fromUrl._url.searchParams) {
902
- if (!intoUrl._url.searchParams.has(key)) {
903
- intoUrl._url.searchParams.set(key, value);
904
- }
905
- }
906
- return intoUrl;
907
- }
908
- static is(value) {
909
- return value instanceof _URI || !!value && typeof value.asURL === "function" && typeof value.getParam === "function" && typeof value.hasParam === "function";
910
- }
911
- // if no protocol is provided, default to file:
912
- static from(strURLUri, defaultProtocol = "file:") {
913
- return from((url) => new _URI(url), strURLUri, defaultProtocol);
914
- }
915
- constructor(url) {
916
- this._url = url;
917
- }
918
- build() {
919
- return BuildURI.from(this.asURL());
920
- }
921
- get hostname() {
922
- return this._url.hostname;
923
- }
924
- get password() {
925
- return this._url.password;
926
- }
927
- get port() {
928
- return this._url.port;
929
- }
930
- get username() {
931
- return this._url.username;
932
- }
933
- get search() {
934
- return this._url.search;
935
- }
936
- get protocol() {
937
- return this._url.protocol;
938
- }
939
- get pathname() {
940
- return this._url.toString().replace(/^.*:\/\//, "").replace(/\?.*$/, "");
941
- }
942
- get hash() {
943
- return this._url.hash;
944
- }
945
- get host() {
946
- return this._url.host;
947
- }
948
- hasParam(key) {
949
- return this._url.searchParams.has(key);
950
- }
951
- getParam(key) {
952
- return falsy2undef(this._url.searchParams.get(key));
953
- }
954
- clone() {
955
- return new _URI(this.asURL());
956
- }
957
- asURL() {
958
- const url = new URL(this._url.toString());
959
- url.searchParams.sort();
960
- return url;
961
- }
962
- toString() {
963
- this._url.searchParams.sort();
964
- return this._url.toString();
965
- }
966
- };
967
-
968
969
  // src/crypto.ts
969
970
  function randomBytes(size) {
970
971
  const bytes = new Uint8Array(size);