@drawnagency/primitives 0.1.29 → 0.1.31
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/dist/auth/index.js +2 -2
- package/dist/{chunk-F3Z6RISI.js → chunk-EUNJDXYX.js} +1 -1
- package/dist/{chunk-F32I6ZZV.js → chunk-PKMPRW7T.js} +1 -1
- package/dist/{chunk-JHSYLVKI.js → chunk-VCZBZMXU.js} +6 -4
- package/dist/{chunk-HXXZBTPF.js → chunk-ZDKSJY2K.js} +1 -1
- package/dist/index.js +4 -4
- package/dist/lib/index.js +2 -2
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +1 -1
- package/package.json +1 -1
- package/src/auth/security.ts +1 -1
- package/src/components/brandguide/Colors.tsx +27 -8
- package/src/media/index.ts +6 -4
package/dist/auth/index.js
CHANGED
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
setSessionCookie,
|
|
7
7
|
signSessionToken,
|
|
8
8
|
verifySessionToken
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-PKMPRW7T.js";
|
|
10
10
|
import {
|
|
11
11
|
isSameOriginRequest,
|
|
12
12
|
requireSessionSecret,
|
|
13
13
|
safeNextPath
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-EUNJDXYX.js";
|
|
15
15
|
export {
|
|
16
16
|
AUDIENCE_COOKIE,
|
|
17
17
|
LastOwnerError,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/auth/security.ts
|
|
2
2
|
function env(key) {
|
|
3
|
-
return import.meta.env?.[key] ?? process.env?.[key] ?? "";
|
|
3
|
+
return import.meta.env?.[key] ?? (typeof process !== "undefined" ? process.env?.[key] : void 0) ?? "";
|
|
4
4
|
}
|
|
5
5
|
function requireSessionSecret() {
|
|
6
6
|
const secret = env("SESSION_SECRET");
|
|
@@ -249,15 +249,17 @@ function generateVideoPoster(blob, quality) {
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
// src/media/index.ts
|
|
252
|
-
var
|
|
252
|
+
var MEDIA_KEY = /* @__PURE__ */ Symbol.for("@drawnagency/primitives/media");
|
|
253
|
+
var _g = globalThis;
|
|
253
254
|
function setMediaProvider(p) {
|
|
254
|
-
|
|
255
|
+
_g[MEDIA_KEY] = p;
|
|
255
256
|
}
|
|
256
257
|
function getMediaProvider() {
|
|
257
|
-
|
|
258
|
+
const provider = _g[MEDIA_KEY];
|
|
259
|
+
if (!provider) {
|
|
258
260
|
throw new Error("No MediaProvider registered. Call setMediaProvider() before using getMediaProvider().");
|
|
259
261
|
}
|
|
260
|
-
return
|
|
262
|
+
return provider;
|
|
261
263
|
}
|
|
262
264
|
|
|
263
265
|
export {
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
safeRedirect,
|
|
28
28
|
sanitizeHtml,
|
|
29
29
|
toSectionId
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-ZDKSJY2K.js";
|
|
31
31
|
import {
|
|
32
32
|
ColorItemSchema,
|
|
33
33
|
ColorSpaceSchema,
|
|
@@ -57,12 +57,12 @@ import {
|
|
|
57
57
|
setSessionCookie,
|
|
58
58
|
signSessionToken,
|
|
59
59
|
verifySessionToken
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-PKMPRW7T.js";
|
|
61
61
|
import {
|
|
62
62
|
isSameOriginRequest,
|
|
63
63
|
requireSessionSecret,
|
|
64
64
|
safeNextPath
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-EUNJDXYX.js";
|
|
66
66
|
import {
|
|
67
67
|
EXT_TO_MIME,
|
|
68
68
|
MIME_TO_EXT,
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
resolveMedia,
|
|
77
77
|
sanitizeMediaName,
|
|
78
78
|
setMediaProvider
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-VCZBZMXU.js";
|
|
80
80
|
import {
|
|
81
81
|
ImageManifestSchema,
|
|
82
82
|
MediaConfigSchema,
|
package/dist/lib/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
safeRedirect,
|
|
18
18
|
sanitizeHtml,
|
|
19
19
|
toSectionId
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-ZDKSJY2K.js";
|
|
21
21
|
import {
|
|
22
22
|
clearRegistry,
|
|
23
23
|
createRegistry,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
registerSchema,
|
|
30
30
|
registerSection
|
|
31
31
|
} from "../chunk-V43WVSVS.js";
|
|
32
|
-
import "../chunk-
|
|
32
|
+
import "../chunk-EUNJDXYX.js";
|
|
33
33
|
import "../chunk-DKOUFIP6.js";
|
|
34
34
|
export {
|
|
35
35
|
buildGoogleFontsUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAKpD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,CAEvD;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAMhD"}
|
package/dist/media/index.js
CHANGED
package/package.json
CHANGED
package/src/auth/security.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
function env(key: string): string {
|
|
7
|
-
return import.meta.env?.[key] ?? process.env?.[key] ?? "";
|
|
7
|
+
return import.meta.env?.[key] ?? (typeof process !== "undefined" ? process.env?.[key] : undefined) ?? "";
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function requireSessionSecret(): Uint8Array {
|
|
@@ -81,12 +81,23 @@ function ColorsView({
|
|
|
81
81
|
showLabel?: boolean;
|
|
82
82
|
}) {
|
|
83
83
|
const [expanded, setExpanded] = useState(!collapsing);
|
|
84
|
-
const [
|
|
84
|
+
const [copiedIndex, setCopiedIndex] = useState<number | null>(null);
|
|
85
85
|
|
|
86
|
-
const handleCopy = (value: string) => {
|
|
87
|
-
navigator.clipboard
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
const handleCopy = (value: string, colorIndex: number) => {
|
|
87
|
+
if (navigator.clipboard?.writeText) {
|
|
88
|
+
navigator.clipboard.writeText(value);
|
|
89
|
+
} else {
|
|
90
|
+
const ta = document.createElement("textarea");
|
|
91
|
+
ta.value = value;
|
|
92
|
+
ta.style.position = "fixed";
|
|
93
|
+
ta.style.opacity = "0";
|
|
94
|
+
document.body.appendChild(ta);
|
|
95
|
+
ta.select();
|
|
96
|
+
document.execCommand("copy");
|
|
97
|
+
document.body.removeChild(ta);
|
|
98
|
+
}
|
|
99
|
+
setCopiedIndex(colorIndex);
|
|
100
|
+
setTimeout(() => setCopiedIndex(null), 1500);
|
|
90
101
|
};
|
|
91
102
|
|
|
92
103
|
return (
|
|
@@ -114,17 +125,25 @@ function ColorsView({
|
|
|
114
125
|
const contrast = getContrastClass(hex);
|
|
115
126
|
return (
|
|
116
127
|
<div key={i} className="overflow-hidden rounded-md border border-base-200">
|
|
117
|
-
<div className={cn("flex min-h-[80px] items-end p-3", contrast)} style={{ backgroundColor: hex || "#ccc" }}>
|
|
128
|
+
<div className={cn("relative flex min-h-[80px] items-end p-3", contrast)} style={{ backgroundColor: hex || "#ccc" }}>
|
|
118
129
|
{color.name && <span className="text-sm font-bold">{color.name}</span>}
|
|
130
|
+
{copiedIndex === i && (
|
|
131
|
+
<span className={cn(
|
|
132
|
+
"absolute top-2 right-2 rounded-full px-2.5 py-0.5 text-xs font-medium",
|
|
133
|
+
getContrastClass(hex) === "text-black" ? "bg-black/15 text-black" : "bg-white/25 text-white",
|
|
134
|
+
)}>
|
|
135
|
+
Copied!
|
|
136
|
+
</span>
|
|
137
|
+
)}
|
|
119
138
|
</div>
|
|
120
139
|
{expanded && (
|
|
121
140
|
<div className="space-y-1 bg-base-accent p-3 text-sm">
|
|
122
141
|
{color.spaces.map((space, j) =>
|
|
123
142
|
Object.entries(space).map(([key, value]) =>
|
|
124
143
|
value ? (
|
|
125
|
-
<button key={`${j}-${key}`} onClick={() => handleCopy(value)} className="cursor-pointer flex w-full justify-between hover:text-primary">
|
|
144
|
+
<button key={`${j}-${key}`} onClick={() => handleCopy(value, i)} className="cursor-pointer flex w-full justify-between hover:text-primary">
|
|
126
145
|
<span className="font-medium uppercase">{key}</span>
|
|
127
|
-
<span>{
|
|
146
|
+
<span>{value}</span>
|
|
128
147
|
</button>
|
|
129
148
|
) : null
|
|
130
149
|
)
|
package/src/media/index.ts
CHANGED
|
@@ -7,15 +7,17 @@ export * from "./queue";
|
|
|
7
7
|
export * from "./resolve";
|
|
8
8
|
export { generateVideoPoster } from "./videoPoster";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const MEDIA_KEY = Symbol.for("@drawnagency/primitives/media");
|
|
11
|
+
const _g = globalThis as Record<symbol, MediaProvider | null>;
|
|
11
12
|
|
|
12
13
|
export function setMediaProvider(p: MediaProvider): void {
|
|
13
|
-
|
|
14
|
+
_g[MEDIA_KEY] = p;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export function getMediaProvider(): MediaProvider {
|
|
17
|
-
|
|
18
|
+
const provider = _g[MEDIA_KEY];
|
|
19
|
+
if (!provider) {
|
|
18
20
|
throw new Error("No MediaProvider registered. Call setMediaProvider() before using getMediaProvider().");
|
|
19
21
|
}
|
|
20
|
-
return
|
|
22
|
+
return provider;
|
|
21
23
|
}
|