@liner-fe/prism 2.1.57 → 2.1.59
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/lib/illust.cjs +121 -0
- package/lib/illust.cjs.map +1 -0
- package/lib/illust.d.cts +28 -0
- package/lib/{index.js → index.cjs} +1770 -1838
- package/lib/index.cjs.map +1 -0
- package/lib/{index.d.ts → index.d.cts} +1 -26
- package/package.json +4 -2
- package/lib/index.js.map +0 -1
package/lib/illust.cjs
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/illust.ts
|
|
32
|
+
var illust_exports = {};
|
|
33
|
+
__export(illust_exports, {
|
|
34
|
+
Illust: () => Illust,
|
|
35
|
+
prefetchIllust: () => prefetchIllust
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(illust_exports);
|
|
38
|
+
|
|
39
|
+
// src/constants/illust/size.ts
|
|
40
|
+
var ratio = { "16:9": { width: 1344, height: 756 }, "4:3": { width: 1008, height: 756 } };
|
|
41
|
+
var illustSize = {
|
|
42
|
+
"object-pencil_paper-16_9": ratio["16:9"],
|
|
43
|
+
"object-smoke-16_9": ratio["16:9"],
|
|
44
|
+
"person-standing_with_a_star-16_9": ratio["16:9"],
|
|
45
|
+
"person-searching-16_9": ratio["16:9"],
|
|
46
|
+
"person-cheerup-16_9": ratio["16:9"],
|
|
47
|
+
"object-graduation_cap_pencil-4_3": ratio["4:3"],
|
|
48
|
+
"object-book_pencil-4_3": ratio["4:3"],
|
|
49
|
+
"object-puzzle-4_3": ratio["4:3"],
|
|
50
|
+
"object-magnifying_glass-4_3": ratio["4:3"],
|
|
51
|
+
"object-lock-4_3": ratio["4:3"],
|
|
52
|
+
"object-empty_box-4_3": ratio["4:3"],
|
|
53
|
+
"person-working_01-4_3": ratio["4:3"],
|
|
54
|
+
"person-searching_01-4_3": ratio["4:3"],
|
|
55
|
+
"person-worried_01-4_3": ratio["4:3"],
|
|
56
|
+
"person-worried_02-4_3": ratio["4:3"],
|
|
57
|
+
"person-worried_03-4_3": ratio["4:3"],
|
|
58
|
+
"person-worried_04-4_3": ratio["4:3"],
|
|
59
|
+
"person-working_02-4_3": ratio["4:3"],
|
|
60
|
+
"person-bye-4_3": ratio["4:3"],
|
|
61
|
+
"person-space_in_work-4_3": ratio["4:3"],
|
|
62
|
+
"person-cheerup-4_3": ratio["4:3"]
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// src/components/Illust/index.tsx
|
|
66
|
+
var import_image = __toESM(require("next/image"), 1);
|
|
67
|
+
|
|
68
|
+
// src/constants/illust/path.ts
|
|
69
|
+
var ILLUST = "/illust";
|
|
70
|
+
var DARK_MODE_ILLUST_PREFIX = `${ILLUST}/dark/`;
|
|
71
|
+
var LIGHT_MODE_ILLUST_PREFIX = `${ILLUST}/light/`;
|
|
72
|
+
|
|
73
|
+
// src/hooks/useIllust.ts
|
|
74
|
+
var import_design_token = require("@liner-fe/design-token");
|
|
75
|
+
var useIllust = /* @__PURE__ */ __name(({ darkSrc, src }) => {
|
|
76
|
+
const { isDarkMode } = (0, import_design_token.useDarkTheme)();
|
|
77
|
+
const sourcePrefix = (() => {
|
|
78
|
+
if (isDarkMode) {
|
|
79
|
+
if (darkSrc?.inverse) {
|
|
80
|
+
return LIGHT_MODE_ILLUST_PREFIX;
|
|
81
|
+
}
|
|
82
|
+
return DARK_MODE_ILLUST_PREFIX;
|
|
83
|
+
}
|
|
84
|
+
if (src.inverse === false) {
|
|
85
|
+
return DARK_MODE_ILLUST_PREFIX;
|
|
86
|
+
}
|
|
87
|
+
return LIGHT_MODE_ILLUST_PREFIX;
|
|
88
|
+
})();
|
|
89
|
+
const currentSourceByColorTheme = isDarkMode ? darkSrc?.name || src.name : src.name;
|
|
90
|
+
return { sourcePrefix, currentSourceByColorTheme, isDarkMode };
|
|
91
|
+
}, "useIllust");
|
|
92
|
+
|
|
93
|
+
// src/components/Illust/index.tsx
|
|
94
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
95
|
+
var Illust = /* @__PURE__ */ __name((props) => {
|
|
96
|
+
const { src, width, margin } = props;
|
|
97
|
+
const { sourcePrefix, currentSourceByColorTheme } = useIllust({
|
|
98
|
+
darkSrc: src.dark,
|
|
99
|
+
src: src.light
|
|
100
|
+
});
|
|
101
|
+
const aspectRatio = illustSize[currentSourceByColorTheme] ? illustSize[currentSourceByColorTheme].width / illustSize[currentSourceByColorTheme].height : void 0;
|
|
102
|
+
const css = {
|
|
103
|
+
width,
|
|
104
|
+
margin
|
|
105
|
+
};
|
|
106
|
+
const source = `${sourcePrefix}${currentSourceByColorTheme}.webp`;
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: css, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
108
|
+
import_image.default,
|
|
109
|
+
{
|
|
110
|
+
alt: currentSourceByColorTheme,
|
|
111
|
+
...props,
|
|
112
|
+
src: source,
|
|
113
|
+
width,
|
|
114
|
+
height: aspectRatio ? width / aspectRatio : width
|
|
115
|
+
}
|
|
116
|
+
) });
|
|
117
|
+
}, "Illust");
|
|
118
|
+
|
|
119
|
+
// src/utils/illust.ts
|
|
120
|
+
var prefetchIllust = /* @__PURE__ */ __name(async ({ name, isDark = false }) => await fetch(`${ILLUST}${isDark ? "/dark/" : "/light/"}${name}.webp`), "prefetchIllust");
|
|
121
|
+
//# sourceMappingURL=illust.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/illust.ts","../src/constants/illust/size.ts","../src/components/Illust/index.tsx","../src/constants/illust/path.ts","../src/hooks/useIllust.ts","../src/utils/illust.ts"],"sourcesContent":["export * from './components/Illust';\nexport * from './utils/illust';\n","import { IllustType } from '@/types/illust';\n\nconst ratio = { '16:9': { width: 1344, height: 756 }, '4:3': { width: 1008, height: 756 } };\n\nexport const illustSize: Partial<Record<IllustType, { width: number; height: number }>> = {\n 'object-pencil_paper-16_9': ratio['16:9'],\n 'object-smoke-16_9': ratio['16:9'],\n 'person-standing_with_a_star-16_9': ratio['16:9'],\n 'person-searching-16_9': ratio['16:9'],\n 'person-cheerup-16_9': ratio['16:9'],\n 'object-graduation_cap_pencil-4_3': ratio['4:3'],\n 'object-book_pencil-4_3': ratio['4:3'],\n 'object-puzzle-4_3': ratio['4:3'],\n 'object-magnifying_glass-4_3': ratio['4:3'],\n 'object-lock-4_3': ratio['4:3'],\n 'object-empty_box-4_3': ratio['4:3'],\n 'person-working_01-4_3': ratio['4:3'],\n 'person-searching_01-4_3': ratio['4:3'],\n 'person-worried_01-4_3': ratio['4:3'],\n 'person-worried_02-4_3': ratio['4:3'],\n 'person-worried_03-4_3': ratio['4:3'],\n 'person-worried_04-4_3': ratio['4:3'],\n 'person-working_02-4_3': ratio['4:3'],\n 'person-bye-4_3': ratio['4:3'],\n 'person-space_in_work-4_3': ratio['4:3'],\n 'person-cheerup-4_3': ratio['4:3'],\n};\n","import { illustSize } from '@/constants/illust/size';\nimport Image, { ImageProps } from 'next/image';\nimport { CSSProperties } from 'react';\nimport { useIllust } from '@/hooks/useIllust';\nimport { IllustType } from '@/types/illust';\nimport { Property } from 'csstype';\n\nexport interface Source<T extends false | true = true> {\n name: IllustType;\n inverse?: T;\n}\n\ninterface IProps extends Omit<ImageProps, 'alt' | 'width' | 'height' | 'fill' | 'src'> {\n width: number;\n src: { light: Source<false>; dark?: Source };\n margin?: Property.Margin<string>;\n}\n\nexport const Illust = (props: IProps) => {\n const { src, width, margin } = props;\n const { sourcePrefix, currentSourceByColorTheme } = useIllust({\n darkSrc: src.dark,\n src: src.light,\n });\n\n const aspectRatio = illustSize[currentSourceByColorTheme]\n ? illustSize[currentSourceByColorTheme].width / illustSize[currentSourceByColorTheme].height\n : undefined;\n\n const css: CSSProperties = {\n width,\n margin,\n };\n\n const source = `${sourcePrefix}${currentSourceByColorTheme}.webp`;\n\n return (\n <div style={css}>\n <Image\n alt={currentSourceByColorTheme}\n {...props}\n src={source}\n width={width}\n height={aspectRatio ? width / aspectRatio : width}\n />\n </div>\n );\n};\n","export const ILLUST = '/illust';\n\nexport const DARK_MODE_ILLUST_PREFIX = `${ILLUST}/dark/`;\nexport const LIGHT_MODE_ILLUST_PREFIX = `${ILLUST}/light/`;\n","import { Source } from '@/components/Illust';\nimport { DARK_MODE_ILLUST_PREFIX, LIGHT_MODE_ILLUST_PREFIX } from '@/constants/illust/path';\nimport { useDarkTheme } from '@liner-fe/design-token';\n\nexport const useIllust = ({ darkSrc, src }: { darkSrc?: Source; src: Source<false> }) => {\n const { isDarkMode } = useDarkTheme();\n\n const sourcePrefix = (() => {\n if (isDarkMode) {\n if (darkSrc?.inverse) {\n return LIGHT_MODE_ILLUST_PREFIX;\n }\n\n return DARK_MODE_ILLUST_PREFIX;\n }\n\n if (src.inverse === false) {\n return DARK_MODE_ILLUST_PREFIX;\n }\n\n return LIGHT_MODE_ILLUST_PREFIX;\n })();\n\n const currentSourceByColorTheme = isDarkMode ? darkSrc?.name || src.name : src.name;\n\n return { sourcePrefix, currentSourceByColorTheme, isDarkMode };\n};\n","import { ILLUST } from '@/constants/illust/path';\nimport { IllustType } from '@/types/illust';\n\nexport const prefetchIllust = async ({ name, isDark = false }: { name: IllustType; isDark?: boolean }) =>\n await fetch(`${ILLUST}${isDark ? '/dark/' : '/light/'}${name}.webp`);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,QAAQ,EAAE,QAAQ,EAAE,OAAO,MAAM,QAAQ,IAAI,GAAG,OAAO,EAAE,OAAO,MAAM,QAAQ,IAAI,EAAE;AAEnF,IAAM,aAA6E;AAAA,EACxF,4BAA4B,MAAM,MAAM;AAAA,EACxC,qBAAqB,MAAM,MAAM;AAAA,EACjC,oCAAoC,MAAM,MAAM;AAAA,EAChD,yBAAyB,MAAM,MAAM;AAAA,EACrC,uBAAuB,MAAM,MAAM;AAAA,EACnC,oCAAoC,MAAM,KAAK;AAAA,EAC/C,0BAA0B,MAAM,KAAK;AAAA,EACrC,qBAAqB,MAAM,KAAK;AAAA,EAChC,+BAA+B,MAAM,KAAK;AAAA,EAC1C,mBAAmB,MAAM,KAAK;AAAA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AM,SAAS,GAAG,YAAY,GAAG,yBAAyB;AAE1D,SACE,4CAAC,SAAI,OAAO,KACV;AAAA,IAAC,aAAAA;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACJ,GAAG;AAAA,MACJ,KAAK;AAAA,MACL;AAAA,MACA,QAAQ,cAAc,QAAQ,cAAc;AAAA;AAAA,EAC9C,GACF;AAEJ,GA7BsB;;;AGff,IAAM,iBAAiB,8BAAO,EAAE,MAAM,SAAS,MAAM,MAC1D,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,WAAW,SAAS,GAAG,IAAI,OAAO,GADvC;","names":["Image"]}
|
package/lib/illust.d.cts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ImageProps } from 'next/image';
|
|
3
|
+
import { Property } from 'csstype';
|
|
4
|
+
|
|
5
|
+
type LightIllustType = "decoration-airplane-1_1" | "decoration-bulb-1_1" | "decoration-car-1_1" | "decoration-coffee-1_1" | "decoration-english-1_1" | "decoration-flag-1_1" | "decoration-hourglass-1_1" | "decoration-money-1_1" | "decoration-palm-1_1" | "decoration-rocket-1_1" | "decoration-shake_hands-1_1" | "decoration-star_01-1_1" | "decoration-star_02-1_1" | "decoration-star_03-1_1" | "decoration-star_04-1_1" | "decoration-star_05-1_1" | "decoration-star_06-1_1" | "decoration-star_07-1_1" | "decoration-star_08-1_1" | "decoration-star_09-1_1" | "decoration-star_10-1_1" | "decoration-star_11-1_1" | "decoration-tennis-1_1" | "object-bomb-1_1" | "object-book_pencil-4_3" | "object-brain-1_1" | "object-clap-1_1" | "object-documents_02-1_1" | "object-empty_box-1_1" | "object-empty_box-4_3" | "object-feather_pen-1_1" | "object-folder_01-1_1" | "object-folder_02-1_1" | "object-free_ticket-1_1" | "object-gift-1_1" | "object-give_gift-1_1" | "object-graduation_cap_pencil-4_3" | "object-lock-4_3" | "object-magnifying_glass-1_1" | "object-magnifying_glass-4_3" | "object-megaphone-1_1" | "object-paper-1_1" | "object-pencil_paper-16_9" | "object-puzzle-4_3" | "object-smoke-16_9" | "object-university_01-1_1" | "object-university_02-1_1" | "object_documents_01-1_1" | "object_find_man-1_1" | "person-ai_writing-1_1" | "person-bye-4_3" | "person-cheerup-16_9" | "person-cheerup-4_3" | "person-holding_a_book-1_1" | "person-introduce-1_1" | "person-introduce-pro-1_1" | "person-make_profile-1_1" | "person-raining-1_1" | "person-searching-16_9" | "person-searching_01-1_1" | "person-searching_01-4_3" | "person-searching_02-1_1" | "person-space_in_work-4_3" | "person-standing_with_a_star-16_9" | "person-time_out_01-1_1" | "person-time_out_02-1_1" | "person-time_out_03-1_1" | "person-time_out_04-1_1" | "person-time_out_05-1_1" | "person-understand-1_1" | "person-working_01-4_3" | "person-working_02-4_3" | "person-worried-1_1" | "person-worried_01-4_3" | "person-worried_02-4_3" | "person-worried_03-4_3" | "person-worried_04-4_3" | "person-writing_01-1_1" | "person-writing_02-1_1";
|
|
6
|
+
type DarkIllustType = "decoration-airplane-1_1" | "decoration-bulb-1_1" | "decoration-car-1_1" | "decoration-flag-1_1" | "decoration-hourglass-1_1" | "decoration-rocket-1_1" | "decoration-star_01-1_1" | "decoration-star_02-1_1" | "decoration-star_03-1_1" | "decoration-star_04-1_1" | "decoration-star_05-1_1" | "decoration-star_06-1_1" | "decoration-star_07-1_1" | "decoration-star_08-1_1" | "decoration-star_09-1_1" | "decoration-star_10-1_1" | "decoration-star_11-1_1" | "object-bomb-1_1" | "object-brain-1_1" | "object-clap-1_1" | "object-documents_02-1_1" | "object-empty_box-1_1" | "object-empty_box-4_3" | "object-folder_01-1_1" | "object-folder_02-1_1" | "object-free_ticket-1_1" | "object-gift-1_1" | "object-give_gift-1_1" | "object-graduation_cap_pencil-4_3" | "object-lock-4_3" | "object-magnifying_glass-1_1" | "object-magnifying_glass-4_3" | "object-megaphone-1_1" | "object-paper-1_1" | "object-pencil_paper-16_9" | "object-puzzle-4_3" | "object-smoke-16_9" | "object_documents_01-1_1" | "object_find_man-1_1" | "person-bye-4_3" | "person-holding_a_book-1_1" | "person-introduce-1_1" | "person-introduce-pro-1_1" | "person-make_profile-1_1" | "person-raining-1_1" | "person-searching-16_9" | "person-searching_01-1_1" | "person-searching_01-4_3" | "person-searching_02-1_1" | "person-space_in_work-4_3" | "person-standing_with_a_star-16_9" | "person-time_out_01-1_1" | "person-time_out_02-1_1" | "person-time_out_03-1_1" | "person-time_out_04-1_1" | "person-time_out_05-1_1" | "person-working_01-4_3" | "person-worried-1_1" | "person-worried_01-4_3" | "person-worried_02-4_3" | "person-worried_03-4_3" | "person-worried_04-4_3" | "person-writing_01-1_1";
|
|
7
|
+
type IllustType = DarkIllustType | LightIllustType;
|
|
8
|
+
|
|
9
|
+
interface Source<T extends false | true = true> {
|
|
10
|
+
name: IllustType;
|
|
11
|
+
inverse?: T;
|
|
12
|
+
}
|
|
13
|
+
interface IProps extends Omit<ImageProps, 'alt' | 'width' | 'height' | 'fill' | 'src'> {
|
|
14
|
+
width: number;
|
|
15
|
+
src: {
|
|
16
|
+
light: Source<false>;
|
|
17
|
+
dark?: Source;
|
|
18
|
+
};
|
|
19
|
+
margin?: Property.Margin<string>;
|
|
20
|
+
}
|
|
21
|
+
declare const Illust: (props: IProps) => react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
declare const prefetchIllust: ({ name, isDark }: {
|
|
24
|
+
name: IllustType;
|
|
25
|
+
isDark?: boolean;
|
|
26
|
+
}) => Promise<Response>;
|
|
27
|
+
|
|
28
|
+
export { Illust, type Source, prefetchIllust };
|