@pdfvector/util 0.0.24 → 0.0.25

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.
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../lib/environment.ts"],"names":[],"mappings":"AAyDA,eAAO,MAAM,IAAI,SAAoC,CAAC;AACtD,eAAO,MAAM,OAAO,SAA0C,CAAC;AAC/D,eAAO,MAAM,MAAM,SAAW,CAAC"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../lib/environment.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,IAAI,SAAiB,CAAC;AACnC,eAAO,MAAM,OAAO,SAAoB,CAAC;AACzC,eAAO,MAAM,MAAM,SAAW,CAAC"}
@@ -1,56 +1,21 @@
1
- function getWithBun(name) {
2
- try {
3
- return Bun.env[name];
4
- }
5
- catch {
6
- return undefined;
7
- }
8
- }
9
- function getWithNode(name) {
10
- try {
11
- return process.env[name];
12
- }
13
- catch {
14
- return undefined;
15
- }
16
- }
17
- function getCIWithNext() {
18
- try {
19
- return process.env["NEXT_PUBLIC_CI"];
20
- }
21
- catch {
22
- return undefined;
23
- }
24
- }
25
- function getCIWithVite() {
26
- try {
27
- return import.meta.env["VITE_CI"];
28
- }
29
- catch {
30
- return undefined;
31
- }
32
- }
33
- function getLocalWithNext() {
34
- try {
35
- return process.env["NEXT_PUBLIC_PDFVECTOR_LOCAL"];
36
- }
37
- catch {
38
- return undefined;
39
- }
40
- }
41
- function getLocalWithVite() {
42
- try {
43
- return import.meta.env["VITE_PDFVECTOR_LOCAL"];
44
- }
45
- catch {
46
- return undefined;
47
- }
48
- }
49
- const envCI = getWithBun("CI") ?? getWithNode("CI") ?? getCIWithNext() ?? getCIWithVite();
50
- const envLocal = getWithBun("PDFVECTOR_LOCAL") ??
51
- getWithNode("PDFVECTOR_LOCAL") ??
52
- getLocalWithNext() ??
53
- getLocalWithVite();
54
- export const isCI = envCI === "1" || envCI === "true";
55
- export const isLocal = envLocal === "1" || envLocal === "true";
1
+ import { readRuntimeEnvironment, safelyReadEnvironment, } from "./read-runtime-environment.js";
2
+ import { resolveEnvironment, runtimeFlags } from "./resolve-environment.js";
3
+ const bunEnvironment = readRuntimeEnvironment(Reflect.get(globalThis, "Bun"));
4
+ const nodeEnvironment = readRuntimeEnvironment(Reflect.get(globalThis, "process"));
5
+ const nextPublicEnvironment = safelyReadEnvironment(() => ({
6
+ NEXT_PUBLIC_CI: process.env["NEXT_PUBLIC_CI"],
7
+ NEXT_PUBLIC_PDFVECTOR_LOCAL: process.env["NEXT_PUBLIC_PDFVECTOR_LOCAL"],
8
+ }));
9
+ const viteEnvironment = safelyReadEnvironment(() => ({
10
+ VITE_CI: import.meta.env["VITE_CI"],
11
+ VITE_PDFVECTOR_LOCAL: import.meta.env["VITE_PDFVECTOR_LOCAL"],
12
+ }));
13
+ const environment = resolveEnvironment([
14
+ runtimeFlags(bunEnvironment),
15
+ runtimeFlags(nodeEnvironment),
16
+ nextPublicEnvironment,
17
+ viteEnvironment,
18
+ ]);
19
+ export const isCI = environment.ci;
20
+ export const isLocal = environment.local;
56
21
  export const isLive = !isLocal;
@@ -0,0 +1,5 @@
1
+ type Environment = Readonly<Record<string, string | undefined>>;
2
+ export declare function safelyReadEnvironment(read: () => Environment): Environment | undefined;
3
+ export declare function readRuntimeEnvironment(value: unknown): Environment | undefined;
4
+ export {};
5
+ //# sourceMappingURL=read-runtime-environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-runtime-environment.d.ts","sourceRoot":"","sources":["../../lib/read-runtime-environment.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAEhE,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,WAAW,GACrB,WAAW,GAAG,SAAS,CAMzB;AAaD,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,OAAO,GACZ,WAAW,GAAG,SAAS,CAOzB"}
@@ -0,0 +1,21 @@
1
+ export function safelyReadEnvironment(read) {
2
+ try {
3
+ return read();
4
+ }
5
+ catch {
6
+ return undefined;
7
+ }
8
+ }
9
+ function isEnvironment(value) {
10
+ return (typeof value === "object" &&
11
+ value !== null &&
12
+ !Array.isArray(value) &&
13
+ Object.values(value).every((entry) => typeof entry === "string" || entry === undefined));
14
+ }
15
+ export function readRuntimeEnvironment(value) {
16
+ if (typeof value !== "object" || value === null || !("env" in value)) {
17
+ return undefined;
18
+ }
19
+ const environment = value.env;
20
+ return isEnvironment(environment) ? environment : undefined;
21
+ }
@@ -0,0 +1,9 @@
1
+ type Environment = Readonly<Record<string, string | undefined>> | undefined;
2
+ interface ResolvedEnvironment {
3
+ ci: boolean;
4
+ local: boolean;
5
+ }
6
+ export declare function runtimeFlags(environment: Environment): Environment;
7
+ export declare function resolveEnvironment(environments: readonly Environment[]): ResolvedEnvironment;
8
+ export {};
9
+ //# sourceMappingURL=resolve-environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-environment.d.ts","sourceRoot":"","sources":["../../lib/resolve-environment.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,SAAS,CAAC;AAE5E,UAAU,mBAAmB;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;CACf;AAID,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAMlE;AAeD,wBAAgB,kBAAkB,CACjC,YAAY,EAAE,SAAS,WAAW,EAAE,GAClC,mBAAmB,CAYrB"}
@@ -0,0 +1,31 @@
1
+ const enabledValues = new Set(["1", "true"]);
2
+ export function runtimeFlags(environment) {
3
+ if (!environment)
4
+ return undefined;
5
+ return {
6
+ CI: environment["CI"],
7
+ PDFVECTOR_LOCAL: environment["PDFVECTOR_LOCAL"],
8
+ };
9
+ }
10
+ function findValue(environments, keys) {
11
+ for (const environment of environments) {
12
+ for (const key of keys) {
13
+ const value = environment?.[key];
14
+ if (value !== undefined)
15
+ return value;
16
+ }
17
+ }
18
+ return undefined;
19
+ }
20
+ export function resolveEnvironment(environments) {
21
+ const ci = findValue(environments, ["CI", "NEXT_PUBLIC_CI", "VITE_CI"]);
22
+ const local = findValue(environments, [
23
+ "PDFVECTOR_LOCAL",
24
+ "NEXT_PUBLIC_PDFVECTOR_LOCAL",
25
+ "VITE_PDFVECTOR_LOCAL",
26
+ ]);
27
+ return {
28
+ ci: ci !== undefined && enabledValues.has(ci),
29
+ local: local !== undefined && enabledValues.has(local),
30
+ };
31
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @pdfvector/util
2
2
 
3
+ ## 0.0.25
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - Add complete unit coverage, strengthen release automation, and remove the legacy E2E workspace.
9
+
3
10
  ## 0.0.24
4
11
  ### Patch Changes
5
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfvector/util",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "main": ".tsc/lib/index.js",
6
6
  "files": [