@reykjavik/webtools 0.1.36 → 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.
Files changed (45) hide show
  1. package/CHANGELOG.md +19 -6
  2. package/CookieHubConsent.d.ts +2 -2
  3. package/CookieHubConsent.js +2 -2
  4. package/README.md +9 -5
  5. package/SiteImprove.d.ts +6 -7
  6. package/SiteImprove.js +23 -37
  7. package/async.d.ts +2 -2
  8. package/async.js +1 -1
  9. package/errorhandling.d.ts +10 -10
  10. package/errorhandling.js +7 -7
  11. package/esm/CookieHubConsent.d.ts +2 -2
  12. package/esm/CookieHubConsent.js +2 -2
  13. package/esm/SiteImprove.d.ts +6 -7
  14. package/esm/SiteImprove.js +23 -14
  15. package/esm/async.d.ts +2 -2
  16. package/esm/async.js +1 -1
  17. package/esm/errorhandling.d.ts +10 -10
  18. package/esm/errorhandling.js +7 -7
  19. package/esm/http.d.ts +5 -5
  20. package/esm/http.js +4 -4
  21. package/esm/index.d.ts +2 -3
  22. package/esm/next/http.d.ts +2 -2
  23. package/esm/next/http.js +3 -3
  24. package/{remix → esm/react-router}/Wait.d.ts +2 -2
  25. package/esm/{remix → react-router}/Wait.js +2 -2
  26. package/esm/{remix → react-router}/http.d.ts +1 -1
  27. package/esm/{remix → react-router}/http.js +1 -1
  28. package/esm/vanillaExtract.d.ts +3 -132
  29. package/esm/vanillaExtract.js +2 -67
  30. package/http.d.ts +5 -5
  31. package/http.js +4 -4
  32. package/index.d.ts +2 -3
  33. package/next/http.d.ts +2 -2
  34. package/next/http.js +3 -3
  35. package/package.json +13 -17
  36. package/{esm/remix → react-router}/Wait.d.ts +2 -2
  37. package/{remix → react-router}/Wait.js +3 -3
  38. package/{remix → react-router}/http.d.ts +1 -1
  39. package/{remix → react-router}/http.js +1 -1
  40. package/vanillaExtract.d.ts +3 -132
  41. package/vanillaExtract.js +3 -70
  42. package/esm/next/SiteImprove.d.ts +0 -10
  43. package/esm/next/SiteImprove.js +0 -7
  44. package/next/SiteImprove.d.ts +0 -10
  45. package/next/SiteImprove.js +0 -10
@@ -2,7 +2,7 @@
2
2
  * Error subclass for thrown values that got cought and turned into an actual
3
3
  * Error, with the thrown value as the `payload` property.
4
4
  *
5
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#aserror
5
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
6
6
  */
7
7
  export declare class ErrorFromPayload extends Error {
8
8
  payload?: unknown;
@@ -17,7 +17,7 @@ export declare class ErrorFromPayload extends Error {
17
17
  * something else it is wrapped in a new `ErrorFromPayload` instance, and the
18
18
  * original value is stored in a `payload`
19
19
  *
20
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#aserror
20
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
21
21
  */
22
22
  export declare const asError: (maybeError: unknown) => ErrorFromPayload;
23
23
  type SuccessResult<T> = [error: undefined, result: T] & {
@@ -31,14 +31,14 @@ type FailResult<E extends Error> = [error: E] & {
31
31
  /**
32
32
  * Simple bare-bones discriminated tuple type for a [error, result] pair.
33
33
  *
34
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#type-resulttuple
34
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#type-resulttuple
35
35
  */
36
36
  export type ResultTuple<T, E extends Error = Error> = [error: undefined, result: T] | [error: E];
37
37
  /**
38
38
  * Discriminated tuple type for a `[error, result]` pair (same as `ResultTuple`)
39
39
  * but with named properties `error` and `result` attached for dev convenience.
40
40
  *
41
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#type-resulttupleobj
41
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#type-resulttupleobj
42
42
  */
43
43
  export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | FailResult<E>;
44
44
  /**
@@ -50,7 +50,7 @@ export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | Fail
50
50
  *
51
51
  * Works on both promises and sync callback functions.
52
52
  *
53
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#resultcatch
53
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultcatch
54
54
  */
55
55
  declare function catch_<T, E extends Error = ErrorFromPayload>(promise: Promise<T>): Promise<ResultTupleObj<T, E>>;
56
56
  declare function catch_<T, E extends Error = ErrorFromPayload>(callback: () => T): ResultTupleObj<T, E>;
@@ -58,19 +58,19 @@ declare function catch_<T, E extends Error = ErrorFromPayload>(callback: () => T
58
58
  * Singleton object with small methods for creating, mapping or handling
59
59
  * `ResultTupleObj` instances.
60
60
  *
61
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#result-singleton
61
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#result-singleton
62
62
  */
63
63
  export declare const Result: {
64
64
  /**
65
65
  * Factory for creating a successful `Result.TupleObj`.
66
66
  *
67
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#resultsuccess
67
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultsuccess
68
68
  */
69
69
  Success: <T>(result: T) => SuccessResult<T>;
70
70
  /**
71
71
  * Factory for creating a failed `Result.TupleObj`.
72
72
  *
73
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#resultsfail
73
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultsfail
74
74
  */
75
75
  Fail: <E extends Error = Error>(e: unknown) => FailResult<E>;
76
76
  catch: typeof catch_;
@@ -79,14 +79,14 @@ export declare const Result: {
79
79
  * object, applying a transformation function to the result, but retaining
80
80
  * the error as-is.
81
81
  *
82
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#resulmap
82
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulmap
83
83
  */
84
84
  map: <T_1, T2, E_1 extends Error>(result: ResultTuple<T_1, E_1>, mapFn: (resultValue: T_1) => T2) => ResultTupleObj<T2, E_1>;
85
85
  /**
86
86
  * Unwraps a discriminated [error, result] `Result.Tuple`-like object
87
87
  * and throws if there's an error, but returns the result otherwise.
88
88
  *
89
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#resulthrow
89
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulthrow
90
90
  */
91
91
  throw: <T_2>(result: ResultTuple<T_2, Error>) => T_2;
92
92
  };
@@ -2,7 +2,7 @@
2
2
  * Error subclass for thrown values that got cought and turned into an actual
3
3
  * Error, with the thrown value as the `payload` property.
4
4
  *
5
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#aserror
5
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
6
6
  */
7
7
  export class ErrorFromPayload extends Error {
8
8
  constructor(payload) {
@@ -23,7 +23,7 @@ export class ErrorFromPayload extends Error {
23
23
  * something else it is wrapped in a new `ErrorFromPayload` instance, and the
24
24
  * original value is stored in a `payload`
25
25
  *
26
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#aserror
26
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
27
27
  */
28
28
  export const asError = (maybeError) => {
29
29
  if (maybeError instanceof Error) {
@@ -56,19 +56,19 @@ function catch_(something) {
56
56
  * Singleton object with small methods for creating, mapping or handling
57
57
  * `ResultTupleObj` instances.
58
58
  *
59
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#result-singleton
59
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#result-singleton
60
60
  */
61
61
  export const Result = {
62
62
  /**
63
63
  * Factory for creating a successful `Result.TupleObj`.
64
64
  *
65
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#resultsuccess
65
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultsuccess
66
66
  */
67
67
  Success,
68
68
  /**
69
69
  * Factory for creating a failed `Result.TupleObj`.
70
70
  *
71
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#resultsfail
71
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultsfail
72
72
  */
73
73
  Fail,
74
74
  // NOTE: The JSDoc must be placed above the `catch_` function above.
@@ -78,7 +78,7 @@ export const Result = {
78
78
  * object, applying a transformation function to the result, but retaining
79
79
  * the error as-is.
80
80
  *
81
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#resulmap
81
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulmap
82
82
  */
83
83
  map: (result, mapFn) => {
84
84
  const [error, resultValue] = result;
@@ -91,7 +91,7 @@ export const Result = {
91
91
  * Unwraps a discriminated [error, result] `Result.Tuple`-like object
92
92
  * and throws if there's an error, but returns the result otherwise.
93
93
  *
94
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#resulthrow
94
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulthrow
95
95
  */
96
96
  throw: (result) => {
97
97
  if (result[0]) {
package/esm/http.d.ts CHANGED
@@ -154,21 +154,21 @@ type TTLObj = {
154
154
  /**
155
155
  * Configures quick TTL-related settings for a HTTP request object
156
156
  *
157
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#type-ttlconfig
157
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#type-ttlconfig
158
158
  */
159
159
  export type TTLConfig = TTL | TTLKeywords | TTLObj;
160
160
  /**
161
161
  * Converts a `TTL` (max-age) value into seconds. Returns `0` for bad and/or
162
162
  * negative input values.
163
163
  *
164
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#tosec-ttl-helper
164
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#tosec-ttl-helper
165
165
  */
166
166
  export declare const toSec: (ttl: TTL) => number;
167
167
  /**
168
168
  * Converts a `TTL` (duration) value into milliseconds. Returns `0` for bad
169
169
  * and/or negative input values.
170
170
  *
171
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#toms-duration-helper
171
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#toms-duration-helper
172
172
  */
173
173
  export declare const toMs: (ttl: TTL) => number;
174
174
  type ServerResponseStub = Pick<ServerResponse, 'setHeader' | 'getHeader' | 'removeHeader'> & {
@@ -181,7 +181,7 @@ type ResponseStub = {
181
181
  * Use this function to quickly set the `Cache-Control` header with a `max-age=`
182
182
  * on a HTTP response
183
183
  *
184
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#cachecontrol-helper
184
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrol-helper
185
185
  */
186
186
  export declare const cacheControl: (response: ServerResponseStub | ResponseStub | Map<string, string> | {
187
187
  res: ServerResponseStub | ResponseStub;
@@ -191,7 +191,7 @@ export declare const cacheControl: (response: ServerResponseStub | ResponseStub
191
191
  * situations requiring a `HeadersInit` compatible object.
192
192
  *
193
193
  * Accepts the same arguments as `cacheControl()`.
194
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#cachecontrolheaders-helper
194
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrolheaders-helper
195
195
  */
196
196
  export declare const cacheControlHeaders: (ttlCfg: TTLConfig, eTag?: string | number) => Record<string, string>;
197
197
  export {};
package/esm/http.js CHANGED
@@ -136,7 +136,7 @@ const unitToSeconds = {
136
136
  * Converts a `TTL` (max-age) value into seconds. Returns `0` for bad and/or
137
137
  * negative input values.
138
138
  *
139
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#tosec-ttl-helper
139
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#tosec-ttl-helper
140
140
  */
141
141
  export const toSec = (ttl) => {
142
142
  if (typeof ttl === 'string') {
@@ -150,7 +150,7 @@ export const toSec = (ttl) => {
150
150
  * Converts a `TTL` (duration) value into milliseconds. Returns `0` for bad
151
151
  * and/or negative input values.
152
152
  *
153
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#toms-duration-helper
153
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#toms-duration-helper
154
154
  */
155
155
  export const toMs = (ttl) => toSec(ttl) * 1000;
156
156
  const toRespnseStubHeaders = (response) => {
@@ -195,7 +195,7 @@ const setCC = (response, cc) => {
195
195
  * Use this function to quickly set the `Cache-Control` header with a `max-age=`
196
196
  * on a HTTP response
197
197
  *
198
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#cachecontrol-helper
198
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrol-helper
199
199
  */
200
200
  // eslint-disable-next-line complexity
201
201
  export const cacheControl = (response, ttlCfg, eTag) => {
@@ -238,7 +238,7 @@ export const cacheControl = (response, ttlCfg, eTag) => {
238
238
  * situations requiring a `HeadersInit` compatible object.
239
239
  *
240
240
  * Accepts the same arguments as `cacheControl()`.
241
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#cachecontrolheaders-helper
241
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrolheaders-helper
242
242
  */
243
243
  export const cacheControlHeaders = (ttlCfg, eTag) => {
244
244
  const headers = new Map();
package/esm/index.d.ts CHANGED
@@ -3,11 +3,10 @@
3
3
  /// <reference path="./async.d.ts" />
4
4
  /// <reference path="./fixIcelandicLocale.d.ts" />
5
5
  /// <reference path="./errorhandling.d.ts" />
6
- /// <reference path="./remix/http.d.ts" />
6
+ /// <reference path="./react-router/http.d.ts" />
7
7
  /// <reference path="./SiteImprove.d.tsx" />
8
8
  /// <reference path="./CookieHubConsent.d.tsx" />
9
- /// <reference path="./remix/Wait.d.tsx" />
10
- /// <reference path="./next/SiteImprove.d.tsx" />
9
+ /// <reference path="./react-router/Wait.d.tsx" />
11
10
  /// <reference path="./next/http.d.tsx" />
12
11
 
13
12
  export {};
@@ -26,7 +26,7 @@ export type InferErrorPageProps<SEP extends ShowErrorPageFn<any>> = Cleanup<Retu
26
26
  * cases when `getServerSideProps` returns an `__error` prop with `statusCode`
27
27
  * and optional friendly `message`.
28
28
  *
29
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README-nextjs.md#makeerrorizeapphoc
29
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#makeerrorizeapphoc
30
30
  */
31
31
  export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorPage: React.FunctionComponent<EP>) => {
32
32
  <P extends {
@@ -48,7 +48,7 @@ export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorP
48
48
  * to return an `HTTP_304_NotModified` response with an empty props object,
49
49
  * in a way that doesn't make TypeScript shout at you.
50
50
  *
51
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README-nextjs.md#notmodified304-helper
51
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#notmodified304-helper
52
52
  */
53
53
  export declare const notModified304: (response: ServerResponse | NextContextLike) => {
54
54
  readonly props: any;
package/esm/next/http.js CHANGED
@@ -9,7 +9,7 @@ export * from '../http.js';
9
9
  * Use this method inside a `getServerSideProps` method (or API route)
10
10
  * to return an error page with proper HTTP status code and all the shit.
11
11
  *
12
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README-nextjs.md#showerrorpage-helper
12
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#showerrorpage-helper
13
13
  */
14
14
  const showErrorPage = (response, error, ttl = '2s') => {
15
15
  error =
@@ -33,7 +33,7 @@ const showErrorPage = (response, error, ttl = '2s') => {
33
33
  * cases when `getServerSideProps` returns an `__error` prop with `statusCode`
34
34
  * and optional friendly `message`.
35
35
  *
36
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README-nextjs.md#makeerrorizeapphoc
36
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#makeerrorizeapphoc
37
37
  */
38
38
  export const makeErrorizeAppHOC = (ErrorPage) => {
39
39
  // the HOC
@@ -62,7 +62,7 @@ export const makeErrorizeAppHOC = (ErrorPage) => {
62
62
  * to return an `HTTP_304_NotModified` response with an empty props object,
63
63
  * in a way that doesn't make TypeScript shout at you.
64
64
  *
65
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README-nextjs.md#notmodified304-helper
65
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#notmodified304-helper
66
66
  */
67
67
  export const notModified304 = (response) => {
68
68
  response = 'res' in response ? response.res : response;
@@ -31,7 +31,7 @@ export type WaitProps<T> = WaitPropsBase<T> & WaitFallbacks;
31
31
  * custom properties for `meanwhile` and `error` fallbacks, and/or other
32
32
  * behaviors.
33
33
  *
34
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README-remix.md#type-waitcomponent
34
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#type-waitcomponent
35
35
  */
36
36
  export type WaitComponent<CustomProps extends Record<string, unknown> = Record<never, never>> = (<T>(props: WaitPropsBase<T> & CustomProps) => ReactElement) & {
37
37
  displayName?: string;
@@ -43,7 +43,7 @@ export type WaitComponent<CustomProps extends Record<string, unknown> = Record<n
43
43
  * If the awaited promise (`props.for`) resolves to an object with a truthy
44
44
  * `$error` property, the `$error` will be thrown.
45
45
  *
46
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README-remix.md#wait-component
46
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#wait-component
47
47
  */
48
48
  export declare const Wait: WaitComponent<WaitFallbacks>;
49
49
  export {};
@@ -1,5 +1,5 @@
1
1
  import React, { Suspense } from 'react';
2
- import { Await } from '@remix-run/react';
2
+ import { Await } from 'react-router';
3
3
  /**
4
4
  * A thin wrapper around [Remix's `Await`](https://remix.run/docs/en/2/components/await)
5
5
  * component, to provide a more ergonomic API.
@@ -7,7 +7,7 @@ import { Await } from '@remix-run/react';
7
7
  * If the awaited promise (`props.for`) resolves to an object with a truthy
8
8
  * `$error` property, the `$error` will be thrown.
9
9
  *
10
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README-remix.md#wait-component
10
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#wait-component
11
11
  */
12
12
  export const Wait = (props) => (React.createElement(Suspense, { fallback: props.meanwhile || 'Loading...' },
13
13
  React.createElement(Await, { resolve: props.for, errorElement: props.error || 'An error occurred.' }, (value) => {
@@ -2,6 +2,6 @@
2
2
  * Detects if the request is a client fetch, or an initial/full-page load.
3
3
  * Useful for deciding whether to defer data fetching or not.
4
4
  *
5
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README-remix.md#isclientfetch
5
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#isclientfetch
6
6
  */
7
7
  export declare const isClientFetch: (request: Request) => boolean;
@@ -2,7 +2,7 @@
2
2
  * Detects if the request is a client fetch, or an initial/full-page load.
3
3
  * Useful for deciding whether to defer data fetching or not.
4
4
  *
5
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README-remix.md#isclientfetch
5
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#isclientfetch
6
6
  */
7
7
  export const isClientFetch = (request) =>
8
8
  // For info about this detection method:
@@ -2,14 +2,14 @@ import { GlobalStyleRule } from '@vanilla-extract/css';
2
2
  /**
3
3
  * Adds free-form CSS as a globalStyle
4
4
  *
5
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#vanillaglobal
5
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillaglobal
6
6
  */
7
7
  export declare const vanillaGlobal: (css: string) => void;
8
8
  /**
9
9
  * Spreads the return value into a style object, to inject free-form CSS
10
10
  * properties (or nested blocks)
11
11
  *
12
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#vanillaprops
12
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillaprops
13
13
  */
14
14
  export declare const vanillaProps: (css: string) => GlobalStyleRule;
15
15
  type ClassNameCallback = (
@@ -27,137 +27,8 @@ classNameSelector: string) => string;
27
27
  *
28
28
  * To opt out of the `&&` replacement, use the callback function signature.
29
29
  *
30
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#vanillaclass
30
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillaclass
31
31
  */
32
32
  export declare function vanillaClass(css: string | ClassNameCallback): string;
33
33
  export declare function vanillaClass(debugId: string, css: string | ClassNameCallback): string;
34
- /**
35
- * @deprecated (Will be removed in v0.2)
36
- *
37
- * Replaces all `&` tokens with the given selector string, in a direct
38
- * (read. "dumb") way. It's mainly useful when used with style-mixins, etc.
39
- *
40
- * **NOTE:** `vanillaNest` does NOT support deeply nested blocks, or anything
41
- * so fancy. It will also replace `&` characters inside values, comments, etc.
42
- * If you need something more sophisticated, use a custom `postcss` config.
43
- *
44
- * ```ts
45
- * // someCssHelper.ts
46
- * import { vanillaNest } from '@reykjavik/webtools/vanillaExtract';
47
- *
48
- * export const hoverGlow = (
49
- * ampSelector: string,
50
- * glowiness?: 'normal' | 'insane'
51
- * ) =>
52
- * vanillaNest(
53
- * ampSelector,
54
- * `
55
- * &:hover {
56
- * box-shadow: 0 0 20px 5px ${
57
- * glowiness === 'insane' ? 'hotpink' : 'salmon'
58
- * };
59
- * }
60
- * `
61
- * );
62
- *
63
- * // ...then, somewhere else in a *.css.ts file:
64
- *
65
- * import { hoverGlow } from '~/someCssHelper.js';
66
- * import { vanillaGlobal } from '@reykjavik/webtools/vanillaExtract';
67
- *
68
- * vanillaGlobal(`
69
- * .MyComponent {
70
- * border: 1px solid #ccc;
71
- * padding: 1em;
72
- * }
73
- * ${hoverGlow('.MyComponent')}
74
- *
75
- * .MyOtherComponent {
76
- * border: 1px solid #ccc;
77
- * padding: 1em;
78
- * }
79
- * ${hoverGlow('.MyOtherComponent', 'insane')}
80
- * `);
81
- * ```
82
- *
83
- * (This low-level utility function is used internally by `vanillaClassNested`.
84
- */
85
- export declare const vanillaNest: (ampSelector: string, css: string) => string;
86
- /**
87
- * @deprecated (Will be removed in v0.2)
88
- *
89
- * Returns a scoped cssClassName styled with free-form CSS.
90
- *
91
- * It also automatically replaces all `&`-tokens with
92
- * the selector for the auto-generated class-name.
93
- *
94
- * ```ts
95
- * // someFile.css.ts
96
- * import { vanillaClassNested } from '@reykjavik/webtools/vanillaExtract';
97
- *
98
- * export const myClass = vanillaClassNested(`
99
- * background-color: #ccc;
100
- * padding: .5em 1em;
101
- *
102
- * /* Nested blocks begin: *​​/
103
- * &:hover {
104
- * background-color: #666;
105
- * color: white;
106
- * }
107
- * & > strong {
108
- * color: maroon;
109
- * }
110
- * html[data-color-theme="unicorn"] & {
111
- * background-color: pink;
112
- * }
113
- * `);
114
- * ```
115
- *
116
- * **NOTE:** All "bare" (un-nested) style properties **must come first**,
117
- * before any nested blocks.
118
- *
119
- * **NOTE 2:** `vanillaClassNested` does NOT support deeply nested blocks, or
120
- * anything so fancy. It will also replace `&` characters inside values,
121
- * comments, etc. If you need something more sophisticated, use a custom
122
- * `postcss` config.
123
- */
124
- export declare function vanillaClassNested(css: string): string;
125
- /** @deprecated (Will be removed in v0.2) */
126
- /**
127
- * Returns a scoped cssClassName styled with free-form CSS.
128
- *
129
- * It also automatically replaces all `&`-tokens with
130
- * the selector for the auto-generated class-name.
131
- *
132
- * ```ts
133
- * // someFile.css.ts
134
- * import { vanillaClassNested } from '@reykjavik/webtools/vanillaExtract';
135
- *
136
- * export const myClass = vanillaClassNested(`
137
- * background-color: #ccc;
138
- * padding: .5em 1em;
139
- *
140
- * /* Nested blocks begin: *​​/
141
- * &:hover {
142
- * background-color: #666;
143
- * color: white;
144
- * }
145
- * & > strong {
146
- * color: maroon;
147
- * }
148
- * html[data-color-theme="unicorn"] & {
149
- * background-color: pink;
150
- * }
151
- * `);
152
- * ```
153
- *
154
- * **NOTE:** All "bare" (un-nested) style properties **must come first**,
155
- * before any nested blocks.
156
- *
157
- * **NOTE 2:** `vanillaClassNested` does NOT support deeply nested blocks, or
158
- * anything so fancy. It will also replace `&` characters inside values,
159
- * comments, etc. If you need something more sophisticated, use a custom
160
- * `postcss` config.
161
- */
162
- export declare function vanillaClassNested(debugId: string, css: string): string;
163
34
  export {};
@@ -2,7 +2,7 @@ import { globalStyle, style } from '@vanilla-extract/css';
2
2
  /**
3
3
  * Adds free-form CSS as a globalStyle
4
4
  *
5
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#vanillaglobal
5
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillaglobal
6
6
  */
7
7
  export const vanillaGlobal = (css) => globalStyle('x', { x: `} ${css} x{x:` });
8
8
  // ---------------------------------------------------------------------------
@@ -10,7 +10,7 @@ export const vanillaGlobal = (css) => globalStyle('x', { x: `} ${css} x{x:` });
10
10
  * Spreads the return value into a style object, to inject free-form CSS
11
11
  * properties (or nested blocks)
12
12
  *
13
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#vanillaprops
13
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#vanillaprops
14
14
  */
15
15
  export const vanillaProps = (css) => ({ x: `; ${css}` });
16
16
  export function vanillaClass(cssOrDebugId, css) {
@@ -25,68 +25,3 @@ export function vanillaClass(cssOrDebugId, css) {
25
25
  : css.replace(/&&/g, `.${className}`));
26
26
  return className;
27
27
  }
28
- // ---------------------------------------------------------------------------
29
- /**
30
- * @deprecated (Will be removed in v0.2)
31
- *
32
- * Replaces all `&` tokens with the given selector string, in a direct
33
- * (read. "dumb") way. It's mainly useful when used with style-mixins, etc.
34
- *
35
- * **NOTE:** `vanillaNest` does NOT support deeply nested blocks, or anything
36
- * so fancy. It will also replace `&` characters inside values, comments, etc.
37
- * If you need something more sophisticated, use a custom `postcss` config.
38
- *
39
- * ```ts
40
- * // someCssHelper.ts
41
- * import { vanillaNest } from '@reykjavik/webtools/vanillaExtract';
42
- *
43
- * export const hoverGlow = (
44
- * ampSelector: string,
45
- * glowiness?: 'normal' | 'insane'
46
- * ) =>
47
- * vanillaNest(
48
- * ampSelector,
49
- * `
50
- * &:hover {
51
- * box-shadow: 0 0 20px 5px ${
52
- * glowiness === 'insane' ? 'hotpink' : 'salmon'
53
- * };
54
- * }
55
- * `
56
- * );
57
- *
58
- * // ...then, somewhere else in a *.css.ts file:
59
- *
60
- * import { hoverGlow } from '~/someCssHelper.js';
61
- * import { vanillaGlobal } from '@reykjavik/webtools/vanillaExtract';
62
- *
63
- * vanillaGlobal(`
64
- * .MyComponent {
65
- * border: 1px solid #ccc;
66
- * padding: 1em;
67
- * }
68
- * ${hoverGlow('.MyComponent')}
69
- *
70
- * .MyOtherComponent {
71
- * border: 1px solid #ccc;
72
- * padding: 1em;
73
- * }
74
- * ${hoverGlow('.MyOtherComponent', 'insane')}
75
- * `);
76
- * ```
77
- *
78
- * (This low-level utility function is used internally by `vanillaClassNested`.
79
- */
80
- export const vanillaNest = (ampSelector, css) => css.replace(/&/g, ampSelector);
81
- export function vanillaClassNested(cssOrDebugId, css) {
82
- const debugId = css != null ? cssOrDebugId : undefined;
83
- css = css != null ? css : cssOrDebugId;
84
- const nestPoint = css.indexOf('&');
85
- const bareStyles = nestPoint > -1 ? css.slice(0, nestPoint) : css;
86
- const nestedStyles = nestPoint > -1 ? css.slice(nestPoint) : undefined;
87
- const className = style(vanillaProps(bareStyles), debugId);
88
- if (nestedStyles) {
89
- vanillaGlobal(vanillaNest(`.${className}`, nestedStyles));
90
- }
91
- return className;
92
- }
package/http.d.ts CHANGED
@@ -154,21 +154,21 @@ type TTLObj = {
154
154
  /**
155
155
  * Configures quick TTL-related settings for a HTTP request object
156
156
  *
157
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#type-ttlconfig
157
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#type-ttlconfig
158
158
  */
159
159
  export type TTLConfig = TTL | TTLKeywords | TTLObj;
160
160
  /**
161
161
  * Converts a `TTL` (max-age) value into seconds. Returns `0` for bad and/or
162
162
  * negative input values.
163
163
  *
164
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#tosec-ttl-helper
164
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#tosec-ttl-helper
165
165
  */
166
166
  export declare const toSec: (ttl: TTL) => number;
167
167
  /**
168
168
  * Converts a `TTL` (duration) value into milliseconds. Returns `0` for bad
169
169
  * and/or negative input values.
170
170
  *
171
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#toms-duration-helper
171
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#toms-duration-helper
172
172
  */
173
173
  export declare const toMs: (ttl: TTL) => number;
174
174
  type ServerResponseStub = Pick<ServerResponse, 'setHeader' | 'getHeader' | 'removeHeader'> & {
@@ -181,7 +181,7 @@ type ResponseStub = {
181
181
  * Use this function to quickly set the `Cache-Control` header with a `max-age=`
182
182
  * on a HTTP response
183
183
  *
184
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#cachecontrol-helper
184
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrol-helper
185
185
  */
186
186
  export declare const cacheControl: (response: ServerResponseStub | ResponseStub | Map<string, string> | {
187
187
  res: ServerResponseStub | ResponseStub;
@@ -191,7 +191,7 @@ export declare const cacheControl: (response: ServerResponseStub | ResponseStub
191
191
  * situations requiring a `HeadersInit` compatible object.
192
192
  *
193
193
  * Accepts the same arguments as `cacheControl()`.
194
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#cachecontrolheaders-helper
194
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrolheaders-helper
195
195
  */
196
196
  export declare const cacheControlHeaders: (ttlCfg: TTLConfig, eTag?: string | number) => Record<string, string>;
197
197
  export {};
package/http.js CHANGED
@@ -140,7 +140,7 @@ const unitToSeconds = {
140
140
  * Converts a `TTL` (max-age) value into seconds. Returns `0` for bad and/or
141
141
  * negative input values.
142
142
  *
143
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#tosec-ttl-helper
143
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#tosec-ttl-helper
144
144
  */
145
145
  const toSec = (ttl) => {
146
146
  if (typeof ttl === 'string') {
@@ -155,7 +155,7 @@ exports.toSec = toSec;
155
155
  * Converts a `TTL` (duration) value into milliseconds. Returns `0` for bad
156
156
  * and/or negative input values.
157
157
  *
158
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#toms-duration-helper
158
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#toms-duration-helper
159
159
  */
160
160
  const toMs = (ttl) => (0, exports.toSec)(ttl) * 1000;
161
161
  exports.toMs = toMs;
@@ -201,7 +201,7 @@ const setCC = (response, cc) => {
201
201
  * Use this function to quickly set the `Cache-Control` header with a `max-age=`
202
202
  * on a HTTP response
203
203
  *
204
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#cachecontrol-helper
204
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrol-helper
205
205
  */
206
206
  // eslint-disable-next-line complexity
207
207
  const cacheControl = (response, ttlCfg, eTag) => {
@@ -245,7 +245,7 @@ exports.cacheControl = cacheControl;
245
245
  * situations requiring a `HeadersInit` compatible object.
246
246
  *
247
247
  * Accepts the same arguments as `cacheControl()`.
248
- * @see https://github.com/reykjavikcity/webtools/blob/v0.1/README.md#cachecontrolheaders-helper
248
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrolheaders-helper
249
249
  */
250
250
  const cacheControlHeaders = (ttlCfg, eTag) => {
251
251
  const headers = new Map();