@drawnagency/primitives 0.1.29 → 0.1.30

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.
@@ -6,12 +6,12 @@ import {
6
6
  setSessionCookie,
7
7
  signSessionToken,
8
8
  verifySessionToken
9
- } from "../chunk-F32I6ZZV.js";
9
+ } from "../chunk-PKMPRW7T.js";
10
10
  import {
11
11
  isSameOriginRequest,
12
12
  requireSessionSecret,
13
13
  safeNextPath
14
- } from "../chunk-F3Z6RISI.js";
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");
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  requireSessionSecret
3
- } from "./chunk-F3Z6RISI.js";
3
+ } from "./chunk-EUNJDXYX.js";
4
4
 
5
5
  // src/auth/cookies.ts
6
6
  import * as jose from "jose";
@@ -249,15 +249,17 @@ function generateVideoPoster(blob, quality) {
249
249
  }
250
250
 
251
251
  // src/media/index.ts
252
- var _provider = null;
252
+ var MEDIA_KEY = /* @__PURE__ */ Symbol.for("@drawnagency/primitives/media");
253
+ var _g = globalThis;
253
254
  function setMediaProvider(p) {
254
- _provider = p;
255
+ _g[MEDIA_KEY] = p;
255
256
  }
256
257
  function getMediaProvider() {
257
- if (!_provider) {
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 _provider;
262
+ return provider;
261
263
  }
262
264
 
263
265
  export {
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-V43WVSVS.js";
7
7
  import {
8
8
  safeNextPath
9
- } from "./chunk-F3Z6RISI.js";
9
+ } from "./chunk-EUNJDXYX.js";
10
10
 
11
11
  // src/lib/cn.ts
12
12
  import { clsx } from "clsx";
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  safeRedirect,
28
28
  sanitizeHtml,
29
29
  toSectionId
30
- } from "./chunk-HXXZBTPF.js";
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-F32I6ZZV.js";
60
+ } from "./chunk-PKMPRW7T.js";
61
61
  import {
62
62
  isSameOriginRequest,
63
63
  requireSessionSecret,
64
64
  safeNextPath
65
- } from "./chunk-F3Z6RISI.js";
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-JHSYLVKI.js";
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-HXXZBTPF.js";
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-F3Z6RISI.js";
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;AAIpD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,CAEvD;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD"}
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"}
@@ -11,7 +11,7 @@ import {
11
11
  resolveMedia,
12
12
  sanitizeMediaName,
13
13
  setMediaProvider
14
- } from "../chunk-JHSYLVKI.js";
14
+ } from "../chunk-VCZBZMXU.js";
15
15
  import {
16
16
  ImageManifestSchema,
17
17
  MediaConfigSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawnagency/primitives",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -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 {
@@ -7,15 +7,17 @@ export * from "./queue";
7
7
  export * from "./resolve";
8
8
  export { generateVideoPoster } from "./videoPoster";
9
9
 
10
- let _provider: MediaProvider | null = null;
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
- _provider = p;
14
+ _g[MEDIA_KEY] = p;
14
15
  }
15
16
 
16
17
  export function getMediaProvider(): MediaProvider {
17
- if (!_provider) {
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 _provider;
22
+ return provider;
21
23
  }