@emabuild/shared 0.1.2 → 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/LICENSE +21 -0
- package/dist/data/html.d.ts +3 -0
- package/dist/data/html.d.ts.map +1 -0
- package/dist/data/html.js +5 -0
- package/dist/data/html.js.map +1 -0
- package/dist/data/records.d.ts +49 -0
- package/dist/data/records.d.ts.map +1 -0
- package/dist/data/records.js +59 -0
- package/dist/data/records.js.map +1 -0
- package/dist/data/text.d.ts +12 -0
- package/dist/data/text.d.ts.map +1 -0
- package/dist/data/text.js +27 -0
- package/dist/data/text.js.map +1 -0
- package/dist/design/body-meta.d.ts.map +1 -1
- package/dist/design/body-meta.js +2 -1
- package/dist/design/body-meta.js.map +1 -1
- package/dist/design/guards.d.ts +7 -0
- package/dist/design/guards.d.ts.map +1 -0
- package/dist/design/guards.js +9 -0
- package/dist/design/guards.js.map +1 -0
- package/dist/http/cors.d.ts +4 -2
- package/dist/http/cors.d.ts.map +1 -1
- package/dist/http/cors.js +21 -5
- package/dist/http/cors.js.map +1 -1
- package/dist/http/fetch-timeout.d.ts +8 -0
- package/dist/http/fetch-timeout.d.ts.map +1 -0
- package/dist/http/fetch-timeout.js +25 -0
- package/dist/http/fetch-timeout.js.map +1 -0
- package/dist/http/json-request.d.ts +12 -0
- package/dist/http/json-request.d.ts.map +1 -0
- package/dist/http/json-request.js +15 -0
- package/dist/http/json-request.js.map +1 -0
- package/dist/http/media-type.d.ts +3 -0
- package/dist/http/media-type.d.ts.map +1 -0
- package/dist/http/media-type.js +5 -0
- package/dist/http/media-type.js.map +1 -0
- package/dist/http/node-handler.d.ts.map +1 -1
- package/dist/http/node-handler.js +2 -2
- package/dist/http/node-handler.js.map +1 -1
- package/dist/images/free-images.d.ts +18 -0
- package/dist/images/free-images.d.ts.map +1 -0
- package/dist/images/free-images.js +19 -0
- package/dist/images/free-images.js.map +1 -0
- package/dist/images/openverse.d.ts.map +1 -1
- package/dist/images/openverse.js +22 -31
- package/dist/images/openverse.js.map +1 -1
- package/dist/images/wikimedia.d.ts +12 -0
- package/dist/images/wikimedia.d.ts.map +1 -0
- package/dist/images/wikimedia.js +57 -0
- package/dist/images/wikimedia.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fabio Varrenti
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/data/html.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/data/html.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module records
|
|
3
|
+
* Type guards and narrowing helpers for untrusted plain data (designs loaded
|
|
4
|
+
* from JSON, request bodies, tool values). One canonical implementation for
|
|
5
|
+
* every package — do not re-declare these locally.
|
|
6
|
+
*/
|
|
7
|
+
/** A string-keyed bag of unknown values */
|
|
8
|
+
export type UnknownRecord = Record<string, unknown>;
|
|
9
|
+
/** Any non-null, non-array object */
|
|
10
|
+
export declare function isRecord(value: unknown): value is UnknownRecord;
|
|
11
|
+
/** A plain `{}` object: not a class instance, array or null */
|
|
12
|
+
export declare function isPlainObject(value: unknown): value is UnknownRecord;
|
|
13
|
+
/** `value` when it is a record, otherwise an empty one */
|
|
14
|
+
export declare function asRecord(value: unknown): UnknownRecord;
|
|
15
|
+
/** The record items of `value` when it is an array, otherwise `[]` */
|
|
16
|
+
export declare function asRecords(value: unknown): UnknownRecord[];
|
|
17
|
+
/** The string items of `value` when it is an array, otherwise `undefined` (so callers pick the fallback) */
|
|
18
|
+
export declare function asStringArray(value: unknown): string[] | undefined;
|
|
19
|
+
/** The number items of `value` when it is an array, otherwise `undefined` */
|
|
20
|
+
export declare function asNumberArray(value: unknown): number[] | undefined;
|
|
21
|
+
/** A non-empty string */
|
|
22
|
+
export declare function isNonEmptyString(value: unknown): value is string;
|
|
23
|
+
/** `value` when it is a string, otherwise `fallback` */
|
|
24
|
+
export declare function asString(value: unknown, fallback?: string): string;
|
|
25
|
+
/** `value` when it is a finite number, otherwise `undefined` */
|
|
26
|
+
export declare function asFiniteNumber(value: unknown): number | undefined;
|
|
27
|
+
/** `value` when it is one of the `allowed` literals, otherwise `undefined` */
|
|
28
|
+
export declare function oneOf<const T extends string | number | boolean>(value: unknown, allowed: readonly T[]): T | undefined;
|
|
29
|
+
/** Keys of `T` whose type admits `undefined` */
|
|
30
|
+
type UndefinedKeys<T> = {
|
|
31
|
+
[K in keyof T]-?: undefined extends T[K] ? K : never;
|
|
32
|
+
}[keyof T];
|
|
33
|
+
/**
|
|
34
|
+
* `T` with every `undefined`-admitting key made optional and
|
|
35
|
+
* `undefined` removed from its type — what `withoutUndefined` returns.
|
|
36
|
+
*/
|
|
37
|
+
export type WithoutUndefined<T> = {
|
|
38
|
+
[K in Exclude<keyof T, UndefinedKeys<T>>]: T[K];
|
|
39
|
+
} & {
|
|
40
|
+
[K in UndefinedKeys<T>]?: Exclude<T[K], undefined>;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Shallow copy of `obj` without the keys whose value is `undefined`.
|
|
44
|
+
* Lets optional fields be built from possibly-missing sources under
|
|
45
|
+
* `exactOptionalPropertyTypes` without conditional spreads at every site.
|
|
46
|
+
*/
|
|
47
|
+
export declare function withoutUndefined<T extends object>(obj: T): WithoutUndefined<T>;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/data/records.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2CAA2C;AAC3C,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,qCAAqC;AACrC,wBAAgB,QAAQ,CAAC,KAAK,E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AAM,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG;KACrF,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;CACnD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAI9E"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module records
|
|
3
|
+
* Type guards and narrowing helpers for untrusted plain data (designs loaded
|
|
4
|
+
* from JSON, request bodies, tool values). One canonical implementation for
|
|
5
|
+
* every package — do not re-declare these locally.
|
|
6
|
+
*/
|
|
7
|
+
/** Any non-null, non-array object */
|
|
8
|
+
export function isRecord(value) {
|
|
9
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
/** A plain `{}` object: not a class instance, array or null */
|
|
12
|
+
export function isPlainObject(value) {
|
|
13
|
+
return isRecord(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
14
|
+
}
|
|
15
|
+
/** `value` when it is a record, otherwise an empty one */
|
|
16
|
+
export function asRecord(value) {
|
|
17
|
+
return isRecord(value) ? value : {};
|
|
18
|
+
}
|
|
19
|
+
/** The record items of `value` when it is an array, otherwise `[]` */
|
|
20
|
+
export function asRecords(value) {
|
|
21
|
+
return Array.isArray(value) ? value.filter(isRecord) : [];
|
|
22
|
+
}
|
|
23
|
+
/** The string items of `value` when it is an array, otherwise `undefined` (so callers pick the fallback) */
|
|
24
|
+
export function asStringArray(value) {
|
|
25
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === 'string') : undefined;
|
|
26
|
+
}
|
|
27
|
+
/** The number items of `value` when it is an array, otherwise `undefined` */
|
|
28
|
+
export function asNumberArray(value) {
|
|
29
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === 'number') : undefined;
|
|
30
|
+
}
|
|
31
|
+
/** A non-empty string */
|
|
32
|
+
export function isNonEmptyString(value) {
|
|
33
|
+
return typeof value === 'string' && value.length > 0;
|
|
34
|
+
}
|
|
35
|
+
/** `value` when it is a string, otherwise `fallback` */
|
|
36
|
+
export function asString(value, fallback = '') {
|
|
37
|
+
return typeof value === 'string' ? value : fallback;
|
|
38
|
+
}
|
|
39
|
+
/** `value` when it is a finite number, otherwise `undefined` */
|
|
40
|
+
export function asFiniteNumber(value) {
|
|
41
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
42
|
+
}
|
|
43
|
+
/** `value` when it is one of the `allowed` literals, otherwise `undefined` */
|
|
44
|
+
export function oneOf(value, allowed) {
|
|
45
|
+
return allowed.find((candidate) => candidate === value);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Shallow copy of `obj` without the keys whose value is `undefined`.
|
|
49
|
+
* Lets optional fields be built from possibly-missing sources under
|
|
50
|
+
* `exactOptionalPropertyTypes` without conditional spreads at every site.
|
|
51
|
+
*/
|
|
52
|
+
export function withoutUndefined(obj) {
|
|
53
|
+
const out = {};
|
|
54
|
+
for (const [key, value] of Object.entries(obj))
|
|
55
|
+
if (value !== undefined)
|
|
56
|
+
out[key] = value;
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/data/records.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,qCAAqC;AACrC,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,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,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AACtD,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,KAAK,CAA4C,KAAc,EAAE,OAAqB;IACpG,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC;AAC1D,CAAC;AAaD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAmB,GAAM;IACvD,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,IAAI,KAAK,KAAK,SAAS;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC1F,OAAO,GAA0B,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module text
|
|
3
|
+
* Invisible-character handling shared by the HTML importer and the
|
|
4
|
+
* plain-text renderer, so every package agrees on what "blank" means.
|
|
5
|
+
*/
|
|
6
|
+
/** Removes the invisible spacer characters */
|
|
7
|
+
export declare function stripInvisible(text: string): string;
|
|
8
|
+
/** Removes invisible spacers and collapses whitespace runs into single spaces, trimmed */
|
|
9
|
+
export declare function collapseBlankText(text: string): string;
|
|
10
|
+
/** Whether `text` holds any visible character (not only whitespace or invisible spacers) */
|
|
11
|
+
export declare function hasVisibleText(text: string): boolean;
|
|
12
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/data/text.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,8CAA8C;AAC9C,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module text
|
|
3
|
+
* Invisible-character handling shared by the HTML importer and the
|
|
4
|
+
* plain-text renderer, so every package agrees on what "blank" means.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Invisible characters email HTML uses as spacers and preheader filler:
|
|
8
|
+
* soft hyphen, combining grapheme joiner, zero-width space/joiners,
|
|
9
|
+
* direction marks, word joiner, BOM.
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line no-misleading-character-class -- invisible characters matched one by one on purpose
|
|
12
|
+
const INVISIBLE = /[\u00AD\u034F\u200B-\u200F\u2060\uFEFF]/g;
|
|
13
|
+
/** Runs of whitespace, including non-breaking and figure spaces */
|
|
14
|
+
const SPACE_RUN = /[\s\u00A0\u2007]+/g;
|
|
15
|
+
/** Removes the invisible spacer characters */
|
|
16
|
+
export function stripInvisible(text) {
|
|
17
|
+
return text.replace(INVISIBLE, '');
|
|
18
|
+
}
|
|
19
|
+
/** Removes invisible spacers and collapses whitespace runs into single spaces, trimmed */
|
|
20
|
+
export function collapseBlankText(text) {
|
|
21
|
+
return stripInvisible(text).replace(SPACE_RUN, ' ').trim();
|
|
22
|
+
}
|
|
23
|
+
/** Whether `text` holds any visible character (not only whitespace or invisible spacers) */
|
|
24
|
+
export function hasVisibleText(text) {
|
|
25
|
+
return collapseBlankText(text) !== '';
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/data/text.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,+GAA+G;AAC/G,MAAM,SAAS,GAAG,0CAA0C,CAAC;AAE7D,mEAAmE;AACnE,MAAM,SAAS,GAAG,oBAAoB,CAAC;AAEvC,8CAA8C;AAC9C,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7D,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-meta.d.ts","sourceRoot":"","sources":["../../src/design/body-meta.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,KAAK,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;AAG5C,2DAA2D;AAC3D,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAA6E,CAAC;AAE/H,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"body-meta.d.ts","sourceRoot":"","sources":["../../src/design/body-meta.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,KAAK,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;AAG5C,2DAA2D;AAC3D,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAA6E,CAAC;AAE/H,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAGnD;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAGjD"}
|
package/dist/design/body-meta.js
CHANGED
|
@@ -7,7 +7,8 @@ export function documentTitle(body, explicit) {
|
|
|
7
7
|
}
|
|
8
8
|
/** `<html lang>` value, or `''` when the design sets none (or an invalid one) */
|
|
9
9
|
export function documentLanguage(body) {
|
|
10
|
-
|
|
10
|
+
const language = body?.language;
|
|
11
|
+
return isLanguageCode(language) ? language : '';
|
|
11
12
|
}
|
|
12
13
|
/** Body font weight as a CSS value (`400`, `bold`…), or `''` */
|
|
13
14
|
export function bodyFontWeight(body) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-meta.js","sourceRoot":"","sources":["../../src/design/body-meta.ts"],"names":[],"mappings":"AASA,MAAM,IAAI,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAErE,2DAA2D;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAU,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,kCAAkC,C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,CAAC;IACzC,OAAO,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EmailDesign } from '@emabuild/types';
|
|
2
|
+
/**
|
|
3
|
+
* Structural check for an untrusted design: an object with `body.rows`.
|
|
4
|
+
* Enough to route a request; deep validation is the consumer's job.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isDesignLike(value: unknown): value is EmailDesign;
|
|
7
|
+
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/design/guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAEjE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isRecord } from '../data/records.js';
|
|
2
|
+
/**
|
|
3
|
+
* Structural check for an untrusted design: an object with `body.rows`.
|
|
4
|
+
* Enough to route a request; deep validation is the consumer's job.
|
|
5
|
+
*/
|
|
6
|
+
export function isDesignLike(value) {
|
|
7
|
+
return isRecord(value) && isRecord(value.body) && Array.isArray(value.body.rows);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/design/guards.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnF,CAAC"}
|
package/dist/http/cors.d.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* @module cors
|
|
3
3
|
* CORS headers for the Fetch-style handlers (AI connector, export service).
|
|
4
4
|
*/
|
|
5
|
-
/** Allowed origins: one origin, a list,
|
|
6
|
-
export type CorsOption = string | string[] | false | undefined;
|
|
5
|
+
/** Allowed origins: one origin, a list, `'*'`, or a predicate on the request's `Origin` */
|
|
6
|
+
export type CorsOption = string | string[] | ((origin: string) => boolean) | false | undefined;
|
|
7
|
+
/** Origins of this machine (`localhost`, `*.localhost`, `127.0.0.1`, `[::1]`), any port and scheme */
|
|
8
|
+
export declare function isLocalOrigin(origin: string): boolean;
|
|
7
9
|
/**
|
|
8
10
|
* Headers allowing `req`'s origin when it is listed in `cors` (`{}` otherwise).
|
|
9
11
|
* `expose` lists response headers the browser may read (e.g. content-disposition).
|
package/dist/http/cors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../src/http/cors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,
|
|
1
|
+
{"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../src/http/cors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,2FAA2F;AAC3F,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,KAAK,GAAG,SAAS,CAAC;AAE/F,sGAAsG;AACtG,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAOrD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBzI"}
|
package/dist/http/cors.js
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
* @module cors
|
|
3
3
|
* CORS headers for the Fetch-style handlers (AI connector, export service).
|
|
4
4
|
*/
|
|
5
|
+
/** Origins of this machine (`localhost`, `*.localhost`, `127.0.0.1`, `[::1]`), any port and scheme */
|
|
6
|
+
export function isLocalOrigin(origin) {
|
|
7
|
+
try {
|
|
8
|
+
const host = new URL(origin).hostname.toLowerCase();
|
|
9
|
+
return host === 'localhost' || host.endsWith('.localhost') || host === '127.0.0.1' || host === '[::1]';
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
5
15
|
/**
|
|
6
16
|
* Headers allowing `req`'s origin when it is listed in `cors` (`{}` otherwise).
|
|
7
17
|
* `expose` lists response headers the browser may read (e.g. content-disposition).
|
|
@@ -10,12 +20,18 @@ export function corsHeaders(req, cors, options = {}) {
|
|
|
10
20
|
if (!cors)
|
|
11
21
|
return {};
|
|
12
22
|
const origin = req.headers.get('origin');
|
|
13
|
-
const list = Array.isArray(cors) ? cors : [cors];
|
|
14
23
|
let allow = null;
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
if (typeof cors === 'function') {
|
|
25
|
+
if (origin && cors(origin))
|
|
26
|
+
allow = origin;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const list = Array.isArray(cors) ? cors : [cors];
|
|
30
|
+
if (list.includes('*'))
|
|
31
|
+
allow = '*';
|
|
32
|
+
else if (origin && list.includes(origin))
|
|
33
|
+
allow = origin;
|
|
34
|
+
}
|
|
19
35
|
if (!allow)
|
|
20
36
|
return {};
|
|
21
37
|
const headers = {
|
package/dist/http/cors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cors.js","sourceRoot":"","sources":["../../src/http/cors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY,EAAE,IAAgB,EAAE,UAAmD,EAAE;IAC/G,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACzC,
|
|
1
|
+
{"version":3,"file":"cors.js","sourceRoot":"","sources":["../../src/http/cors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,sGAAsG;AACtG,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QACpD,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,OAAO,CAAC;IACzG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY,EAAE,IAAgB,EAAE,UAAmD,EAAE;IAC/G,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,KAAK,GAAkB,IAAI,CAAC;IAChC,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,IAAI,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;YAAE,KAAK,GAAG,MAAM,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,KAAK,GAAG,GAAG,CAAC;aAC/B,IAAI,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,KAAK,GAAG,MAAM,CAAC;IAC3D,CAAC;IACD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,MAAM,OAAO,GAA2B;QACtC,6BAA6B,EAAE,KAAK;QACpC,8BAA8B,EAAE,OAAO,CAAC,OAAO,IAAI,eAAe;QAClE,8BAA8B,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,IAAI,6BAA6B;QAClH,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,+BAA+B,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjG,wBAAwB,EAAE,OAAO;KAClC,CAAC;IACF,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC;IAC3C,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module http/fetch-timeout
|
|
3
|
+
* `fetch` that gives up after `ms` (slow public APIs must not hang the UI)
|
|
4
|
+
* and still honours the caller's AbortSignal. A timeout rejects with
|
|
5
|
+
* `${label} did not respond in time`; a caller abort rejects as fetch does.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fetchWithTimeout(url: string, ms: number, label: string, signal?: AbortSignal, init?: RequestInit): Promise<Response>;
|
|
8
|
+
//# sourceMappingURL=fetch-timeout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-timeout.d.ts","sourceRoot":"","sources":["../../src/http/fetch-timeout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAc9I"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module http/fetch-timeout
|
|
3
|
+
* `fetch` that gives up after `ms` (slow public APIs must not hang the UI)
|
|
4
|
+
* and still honours the caller's AbortSignal. A timeout rejects with
|
|
5
|
+
* `${label} did not respond in time`; a caller abort rejects as fetch does.
|
|
6
|
+
*/
|
|
7
|
+
export async function fetchWithTimeout(url, ms, label, signal, init = {}) {
|
|
8
|
+
const ctrl = new AbortController();
|
|
9
|
+
const timer = setTimeout(() => ctrl.abort(), ms);
|
|
10
|
+
const onAbort = () => ctrl.abort();
|
|
11
|
+
signal?.addEventListener('abort', onAbort);
|
|
12
|
+
try {
|
|
13
|
+
return await fetch(url, { ...init, signal: ctrl.signal });
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
if (ctrl.signal.aborted && !signal?.aborted)
|
|
17
|
+
throw new Error(`${label} did not respond in time`);
|
|
18
|
+
throw err;
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
signal?.removeEventListener('abort', onAbort);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=fetch-timeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-timeout.js","sourceRoot":"","sources":["../../src/http/fetch-timeout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,GAAW,EAAE,EAAU,EAAE,KAAa,EAAE,MAAoB,EAAE,OAAoB,EAAE;IACzH,MAAM,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACnC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC3C,IAAI,CAAC;QACH,OAAO,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,0BAA0B,CAAC,CAAC;QACjG,MAAM,GAAG,CAAC;IACZ,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module json-request
|
|
3
|
+
*
|
|
4
|
+
* The handlers only accept `Content-Type: application/json` POSTs. Browsers
|
|
5
|
+
* send that content type cross-origin only after a CORS preflight, so a page
|
|
6
|
+
* on another origin cannot fire requests at a handler (e.g. a local AI server
|
|
7
|
+
* spending the developer's API key) with a "simple" `text/plain` or form POST,
|
|
8
|
+
* whatever the CORS settings say.
|
|
9
|
+
*/
|
|
10
|
+
/** Whether the request declares a JSON body (`application/json`, any parameters) */
|
|
11
|
+
export declare function isJsonRequest(req: Request): boolean;
|
|
12
|
+
//# sourceMappingURL=json-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-request.d.ts","sourceRoot":"","sources":["../../src/http/json-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEnD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module json-request
|
|
3
|
+
*
|
|
4
|
+
* The handlers only accept `Content-Type: application/json` POSTs. Browsers
|
|
5
|
+
* send that content type cross-origin only after a CORS preflight, so a page
|
|
6
|
+
* on another origin cannot fire requests at a handler (e.g. a local AI server
|
|
7
|
+
* spending the developer's API key) with a "simple" `text/plain` or form POST,
|
|
8
|
+
* whatever the CORS settings say.
|
|
9
|
+
*/
|
|
10
|
+
import { mediaType } from './media-type.js';
|
|
11
|
+
/** Whether the request declares a JSON body (`application/json`, any parameters) */
|
|
12
|
+
export function isJsonRequest(req) {
|
|
13
|
+
return mediaType(req.headers.get('content-type')) === 'application/json';
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=json-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-request.js","sourceRoot":"","sources":["../../src/http/json-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,oFAAoF;AACpF,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,OAAO,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,KAAK,kBAAkB,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-type.d.ts","sourceRoot":"","sources":["../../src/http/media-type.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAEnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-type.js","sourceRoot":"","sources":["../../src/http/media-type.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,UAAU,SAAS,CAAC,MAAiC;IACzD,OAAO,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-handler.d.ts","sourceRoot":"","sources":["../../src/http/node-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"node-handler.d.ts","sourceRoot":"","sources":["../../src/http/node-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGjE,gCAAgC;AAChC,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE1E,4CAA4C;AAC5C,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,eAAe,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/D,GAAG,EAAE,cAAc,EACnB,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,KAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;AAuCnB;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CA0DhE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withoutUndefined } from '../data/records.js';
|
|
1
2
|
async function readBody(req) {
|
|
2
3
|
const method = (req.method ?? 'GET').toUpperCase();
|
|
3
4
|
if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS')
|
|
@@ -59,9 +60,8 @@ export function toNodeHandler(handler) {
|
|
|
59
60
|
const url = new URL(req.originalUrl ?? req.url ?? '/', `${proto}://${host}`);
|
|
60
61
|
const body = await readBody(req);
|
|
61
62
|
const request = new Request(url, {
|
|
62
|
-
method: req.method,
|
|
63
|
+
...withoutUndefined({ method: req.method, body }),
|
|
63
64
|
headers: toHeaders(req),
|
|
64
|
-
body,
|
|
65
65
|
signal: abort.signal,
|
|
66
66
|
});
|
|
67
67
|
const response = await handler(request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-handler.js","sourceRoot":"","sources":["../../src/http/node-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-handler.js","sourceRoot":"","sources":["../../src/http/node-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAYtD,KAAK,UAAU,QAAQ,CAAC,GAAyC;IAC/D,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IACnD,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACpF,qEAAqE;IACrE,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC3B,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC;QAClD,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG;QAAE,MAAM,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,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,iCAAiC,EAAE,CAAC,CAAC;gBAC1E,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC;YAC9D,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,OAAO,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module free-images
|
|
3
|
+
* Free (CC0 / public-domain) image search for the editor's picker and the AI
|
|
4
|
+
* `search_images` tool: Openverse first, Wikimedia Commons when Openverse
|
|
5
|
+
* fails or times out. A caller abort is never retried.
|
|
6
|
+
*/
|
|
7
|
+
import type { FreeImage } from '@emabuild/types';
|
|
8
|
+
import { type OpenverseOptions } from './openverse.js';
|
|
9
|
+
export type FreeImageSource = 'openverse' | 'wikimedia';
|
|
10
|
+
export interface FreeImageSearchResult {
|
|
11
|
+
images: FreeImage[];
|
|
12
|
+
hasMore: boolean;
|
|
13
|
+
/** Where the results came from */
|
|
14
|
+
source: FreeImageSource;
|
|
15
|
+
}
|
|
16
|
+
/** `licenses` applies to Openverse; the fallback always returns CC0 / public domain only */
|
|
17
|
+
export declare function searchFreeImages(query: string, options?: OpenverseOptions): Promise<FreeImageSearchResult>;
|
|
18
|
+
//# sourceMappingURL=free-images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"free-images.d.ts","sourceRoot":"","sources":["../../src/images/free-images.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,WAAW,CAAC;AAExD,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,kCAAkC;IAClC,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,4FAA4F;AAC5F,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAWpH"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { searchOpenverse } from './openverse.js';
|
|
2
|
+
import { searchWikimedia } from './wikimedia.js';
|
|
3
|
+
/** `licenses` applies to Openverse; the fallback always returns CC0 / public domain only */
|
|
4
|
+
export async function searchFreeImages(query, options = {}) {
|
|
5
|
+
try {
|
|
6
|
+
return { ...(await searchOpenverse(query, options)), source: 'openverse' };
|
|
7
|
+
}
|
|
8
|
+
catch (err) {
|
|
9
|
+
if (options.signal?.aborted)
|
|
10
|
+
throw err;
|
|
11
|
+
try {
|
|
12
|
+
return { ...(await searchWikimedia(query, options)), source: 'wikimedia' };
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw err; // report the primary failure
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=free-images.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"free-images.js","sourceRoot":"","sources":["../../src/images/free-images.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAyB,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAWjD,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAa,EAAE,UAA4B,EAAE;IAClF,IAAI,CAAC;QACH,OAAO,EAAE,GAAG,CAAC,MAAM,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAC7E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO;YAAE,MAAM,GAAG,CAAC;QACvC,IAAI,CAAC;YACH,OAAO,EAAE,GAAG,CAAC,MAAM,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QAC7E,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,GAAG,CAAC,CAAC,6BAA6B;QAC1C,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openverse.d.ts","sourceRoot":"","sources":["../../src/images/openverse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"openverse.d.ts","sourceRoot":"","sources":["../../src/images/openverse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAqBzE,MAAM,WAAW,gBAAiB,SAAQ,sBAAsB;IAC9D,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA8BvI"}
|
package/dist/images/openverse.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { fetchWithTimeout } from '../http/fetch-timeout.js';
|
|
2
|
+
import { withoutUndefined } from '../data/records.js';
|
|
1
3
|
const API = 'https://api.openverse.org/v1/images/';
|
|
2
4
|
const ASPECT = { landscape: 'wide', portrait: 'tall', square: 'square' };
|
|
3
5
|
const TIMEOUT_MS = 12000;
|
|
@@ -13,36 +15,25 @@ export async function searchOpenverse(query, options = {}) {
|
|
|
13
15
|
if (options.orientation)
|
|
14
16
|
params.set('aspect_ratio', ASPECT[options.orientation]);
|
|
15
17
|
// Openverse can be slow: give up after a while instead of hanging the UI
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return { images, hasMore: (options.page ?? 1) < (data.page_count ?? 1) };
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
if (ctrl.signal.aborted && !options.signal?.aborted)
|
|
40
|
-
throw new Error('Openverse did not respond in time');
|
|
41
|
-
throw err;
|
|
42
|
-
}
|
|
43
|
-
finally {
|
|
44
|
-
clearTimeout(timer);
|
|
45
|
-
options.signal?.removeEventListener('abort', onAbort);
|
|
46
|
-
}
|
|
18
|
+
const res = await fetchWithTimeout(`${API}?${params}`, TIMEOUT_MS, 'Openverse', options.signal);
|
|
19
|
+
if (!res.ok)
|
|
20
|
+
throw new Error(`Openverse ${res.status}`);
|
|
21
|
+
const data = await res.json();
|
|
22
|
+
const images = (data.results ?? []).flatMap((r) => {
|
|
23
|
+
if (!r.url)
|
|
24
|
+
return [];
|
|
25
|
+
return [withoutUndefined({
|
|
26
|
+
url: r.url.replace(/^http:/, 'https:'),
|
|
27
|
+
thumbnail: r.thumbnail || r.url,
|
|
28
|
+
width: r.width ?? undefined,
|
|
29
|
+
height: r.height ?? undefined,
|
|
30
|
+
title: r.title || undefined,
|
|
31
|
+
creator: r.creator || undefined,
|
|
32
|
+
license: r.license,
|
|
33
|
+
licenseUrl: r.license_url || undefined,
|
|
34
|
+
landingUrl: r.foreign_landing_url || undefined,
|
|
35
|
+
})];
|
|
36
|
+
});
|
|
37
|
+
return { images, hasMore: (options.page ?? 1) < (data.page_count ?? 1) };
|
|
47
38
|
}
|
|
48
39
|
//# sourceMappingURL=openverse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openverse.js","sourceRoot":"","sources":["../../src/images/openverse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openverse.js","sourceRoot":"","sources":["../../src/images/openverse.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,GAAG,GAAG,sCAAsC,CAAC;AACnD,MAAM,MAAM,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAW,CAAC;AAClF,MAAM,UAAU,GAAG,KAAK,CAAC;AAoBzB,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,KAAa,EAAE,UAA4B,EAAE;IACjF,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QACjC,CAAC,EAAE,KAAK;QACR,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;QACtC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;QAC/B,MAAM,EAAE,OAAO;QACf,SAAS,EAAE,SAAS;KACrB,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,WAAW;QAAE,MAAM,CAA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AAC,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module wikimedia
|
|
3
|
+
* Wikimedia Commons image search (no API key), used as the fallback when
|
|
4
|
+
* Openverse fails. Only CC0 and public-domain files are returned, like the
|
|
5
|
+
* Openverse default, so images need no attribution.
|
|
6
|
+
*/
|
|
7
|
+
import type { FreeImage, FreeImageSearchOptions } from '@emabuild/types';
|
|
8
|
+
export declare function searchWikimedia(query: string, options?: FreeImageSearchOptions): Promise<{
|
|
9
|
+
images: FreeImage[];
|
|
10
|
+
hasMore: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=wikimedia.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wikimedia.d.ts","sourceRoot":"","sources":["../../src/images/wikimedia.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AA8BzE,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAsC7I"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { fetchWithTimeout } from '../http/fetch-timeout.js';
|
|
2
|
+
import { withoutUndefined } from '../data/records.js';
|
|
3
|
+
const API = 'https://commons.wikimedia.org/w/api.php';
|
|
4
|
+
const TIMEOUT_MS = 10000;
|
|
5
|
+
/** Licenses that need no attribution */
|
|
6
|
+
const FREE_LICENSE = /^(cc0|cc-zero|public domain|pd(\b|-))/i;
|
|
7
|
+
const plain = (html) => html?.replace(/<[^>]*>/g, '').replace(/\s+/g, ' ').trim() || undefined;
|
|
8
|
+
function matchesOrientation(w, h, o) {
|
|
9
|
+
if (!o || !w || !h)
|
|
10
|
+
return true;
|
|
11
|
+
const r = w / h;
|
|
12
|
+
return o === 'landscape' ? r > 1.15 : o === 'portrait' ? r < 0.87 : r >= 0.87 && r <= 1.15;
|
|
13
|
+
}
|
|
14
|
+
export async function searchWikimedia(query, options = {}) {
|
|
15
|
+
const count = Math.min(Math.max(options.count ?? 20, 1), 20);
|
|
16
|
+
// Ask for more than needed: non-free licenses and other orientations are filtered out here
|
|
17
|
+
const batch = Math.min(count * 3, 50);
|
|
18
|
+
const params = new URLSearchParams({
|
|
19
|
+
action: 'query', format: 'json', origin: '*',
|
|
20
|
+
generator: 'search', gsrnamespace: '6', gsrsearch: `${query} filetype:bitmap`,
|
|
21
|
+
gsrlimit: String(batch), gsroffset: String(((options.page ?? 1) - 1) * batch),
|
|
22
|
+
prop: 'imageinfo', iiprop: 'url|size|mime|extmetadata', iiurlwidth: '400',
|
|
23
|
+
iiextmetadatafilter: 'LicenseShortName|License|LicenseUrl|Artist|ObjectName',
|
|
24
|
+
});
|
|
25
|
+
// Browsers cannot set User-Agent; servers identify the client as Wikimedia asks (no personal data)
|
|
26
|
+
const headers = typeof window === 'undefined' ? { 'Api-User-Agent': 'emabuild-editor (https://www.npmjs.com/package/@emabuild/core)' } : undefined;
|
|
27
|
+
const res = await fetchWithTimeout(`${API}?${params}`, TIMEOUT_MS, 'Wikimedia Commons', options.signal, headers ? { headers } : {});
|
|
28
|
+
if (!res.ok)
|
|
29
|
+
throw new Error(`Wikimedia Commons ${res.status}`);
|
|
30
|
+
const data = await res.json();
|
|
31
|
+
const pages = Object.values(data.query?.pages ?? {}).sort((a, b) => (a.index ?? 0) - (b.index ?? 0));
|
|
32
|
+
const images = [];
|
|
33
|
+
for (const p of pages) {
|
|
34
|
+
const info = p.imageinfo?.[0];
|
|
35
|
+
const meta = info?.extmetadata ?? {};
|
|
36
|
+
const license = meta.LicenseShortName?.value ?? meta.License?.value ?? '';
|
|
37
|
+
if (!info?.url || !FREE_LICENSE.test(license) || !/^image\/(jpeg|png)$/.test(info.mime ?? ''))
|
|
38
|
+
continue;
|
|
39
|
+
if (!matchesOrientation(info.width ?? 0, info.height ?? 0, options.orientation))
|
|
40
|
+
continue;
|
|
41
|
+
images.push(withoutUndefined({
|
|
42
|
+
url: info.url,
|
|
43
|
+
thumbnail: info.thumburl || info.url,
|
|
44
|
+
width: info.width,
|
|
45
|
+
height: info.height,
|
|
46
|
+
title: plain(meta.ObjectName?.value) ?? p.title?.replace(/^File:/, '').replace(/\.\w+$/, ''),
|
|
47
|
+
creator: plain(meta.Artist?.value),
|
|
48
|
+
license: /^cc0|cc-zero/i.test(license) ? 'cc0' : 'pdm',
|
|
49
|
+
licenseUrl: meta.LicenseUrl?.value,
|
|
50
|
+
landingUrl: info.descriptionurl,
|
|
51
|
+
}));
|
|
52
|
+
if (images.length >= count)
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return { images, hasMore: !!data.continue };
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=wikimedia.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wikimedia.js","sourceRoot":"","sources":["../../src/images/wikimedia.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,GAAG,GAAG,yCAAyC,CAAC;AACtD,MAAM,UAAU,GAAG,KAAK,CAAC;AACzB,wCAAwC;AACxC,MAAM,YAAY,GAAG,wCAAwC,CAAC;AAe9D,MAAM,KAAK,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,SAAS,CAAC;AAExG,SAAS,kBAAkB,CAAC,CAAS,EAAE,CAAS,EAAE,CAAwC;IACxF,IAAI,CAA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I,CAAC,KAAK,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC;YAAE,SAAS;QAC1F,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAC3B,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,GAAG;YACpC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC5F,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;YAClC,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK;YACtD,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK;YAClC,UAAU,EAAE,IAAI,CAAC,cAAc;SAChC,CAAC,CAAC,CAAC;QACJ,IAAI,MAAM,CAAC,MAAM,IAAI,KAAK;YAAE,MAAM;IACpC,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AAC9C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,18 @@
|
|
|
3
3
|
* grouped by scope. Isomorphic entry (browser + Node); Node-only helpers are in
|
|
4
4
|
* `@emabuild/shared/node`.
|
|
5
5
|
*/
|
|
6
|
-
export { corsHeaders, type CorsOption } from './http/cors.js';
|
|
6
|
+
export { corsHeaders, isLocalOrigin, type CorsOption } from './http/cors.js';
|
|
7
|
+
export { isJsonRequest } from './http/json-request.js';
|
|
8
|
+
export { mediaType } from './http/media-type.js';
|
|
7
9
|
export { searchOpenverse } from './images/openverse.js';
|
|
10
|
+
export { searchWikimedia } from './images/wikimedia.js';
|
|
11
|
+
export { searchFreeImages, type FreeImageSearchResult, type FreeImageSource } from './images/free-images.js';
|
|
12
|
+
export { fetchWithTimeout } from './http/fetch-timeout.js';
|
|
8
13
|
export { cleanCssValue, isSafeCssValue } from './css/css-safe.js';
|
|
9
14
|
export { allRows } from './design/rows.js';
|
|
15
|
+
export { isDesignLike } from './design/guards.js';
|
|
10
16
|
export { documentTitle, documentLanguage, bodyFontWeight, isLanguageCode } from './design/body-meta.js';
|
|
17
|
+
export { isRecord, isPlainObject, asRecord, asRecords, asStringArray, asNumberArray, isNonEmptyString, asString, asFiniteNumber, oneOf, withoutUndefined, type UnknownRecord, type WithoutUndefined, } from './data/records.js';
|
|
18
|
+
export { escapeHtmlText } from './data/html.js';
|
|
19
|
+
export { stripInvisible, collapseBlankText, hasVisibleText } from './data/text.js';
|
|
11
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EACL,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,SAAS,EACT,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,KAAK,EACL,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,18 @@
|
|
|
3
3
|
* grouped by scope. Isomorphic entry (browser + Node); Node-only helpers are in
|
|
4
4
|
* `@emabuild/shared/node`.
|
|
5
5
|
*/
|
|
6
|
-
export { corsHeaders } from './http/cors.js';
|
|
6
|
+
export { corsHeaders, isLocalOrigin } from './http/cors.js';
|
|
7
|
+
export { isJsonRequest } from './http/json-request.js';
|
|
8
|
+
export { mediaType } from './http/media-type.js';
|
|
7
9
|
export { searchOpenverse } from './images/openverse.js';
|
|
10
|
+
export { searchWikimedia } from './images/wikimedia.js';
|
|
11
|
+
export { searchFreeImages } from './images/free-images.js';
|
|
12
|
+
export { fetchWithTimeout } from './http/fetch-timeout.js';
|
|
8
13
|
export { cleanCssValue, isSafeCssValue } from './css/css-safe.js';
|
|
9
14
|
export { allRows } from './design/rows.js';
|
|
15
|
+
export { isDesignLike } from './design/guards.js';
|
|
10
16
|
export { documentTitle, documentLanguage, bodyFontWeight, isLanguageCode } from './design/body-meta.js';
|
|
17
|
+
export { isRecord, isPlainObject, asRecord, asRecords, asStringArray, asNumberArray, isNonEmptyString, asString, asFiniteNumber, oneOf, withoutUndefined, } from './data/records.js';
|
|
18
|
+
export { escapeHtmlText } from './data/html.js';
|
|
19
|
+
export { stripInvisible, collapseBlankText, hasVisibleText } from './data/text.js';
|
|
11
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAmB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAmB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAoD,MAAM,yBAAyB,CAAC;AAC7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EACL,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,SAAS,EACT,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,KAAK,EACL,gBAAgB,GAGjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emabuild/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Internal building blocks shared by the @emabuild packages (HTTP adapters, image search)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
21
|
-
"README.md"
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
22
23
|
],
|
|
23
24
|
"sideEffects": false,
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@emabuild/types": "^0.
|
|
26
|
+
"@emabuild/types": "^0.8.1"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/node": "^22.10.0",
|
|
@@ -36,10 +37,16 @@
|
|
|
36
37
|
"publishConfig": {
|
|
37
38
|
"access": "public"
|
|
38
39
|
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/Fabiovarrenti/emabuild.git",
|
|
43
|
+
"directory": "packages/shared"
|
|
44
|
+
},
|
|
39
45
|
"scripts": {
|
|
40
46
|
"build": "tsc -p tsconfig.json",
|
|
41
47
|
"dev": "tsc -p tsconfig.json --watch",
|
|
42
48
|
"clean": "rm -rf dist",
|
|
43
|
-
"test": "vitest run"
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"typecheck": "tsc --noEmit -p ."
|
|
44
51
|
}
|
|
45
52
|
}
|