@kitsy/cnos 1.4.0 → 1.5.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/README.md CHANGED
@@ -19,4 +19,4 @@ CLI-oriented storage/export rules to be aware of:
19
19
  - shell env export comes from explicit `envMapping.explicit`
20
20
  - local secret material lives outside the repo in encrypted vault storage under `~/.cnos/secrets`
21
21
 
22
- Use `@kitsy/cnos-vite` for Vite projects and `@kitsy/cnos-next` for Next.js projects when you want CNOS public values projected into framework-native env surfaces and embedded for `@kitsy/cnos/browser`.
22
+ Use `@kitsy/cnos-vite` for Vite projects, `@kitsy/cnos-next` for Next.js projects, and `@kitsy/cnos-webpack` for webpack/static bundles when you want CNOS public values projected into framework-native env surfaces and embedded for `@kitsy/cnos/browser`.
@@ -30,7 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/build/index.ts
31
31
  var build_exports = {};
32
32
  __export(build_exports, {
33
- resolveBrowserData: () => resolveBrowserData
33
+ resolveBrowserData: () => resolveBrowserData,
34
+ resolveFrameworkEnv: () => resolveFrameworkEnv,
35
+ toFrameworkEnv: () => toFrameworkEnv
34
36
  });
35
37
  module.exports = __toCommonJS(build_exports);
36
38
 
@@ -2317,7 +2319,7 @@ function envVarToLogicalKey(envVar, config = {}) {
2317
2319
  // package.json
2318
2320
  var package_default = {
2319
2321
  name: "@kitsy/cnos",
2320
- version: "1.4.0",
2322
+ version: "1.5.0",
2321
2323
  description: "Batteries-included CNOS runtime package wired with the official plugins.",
2322
2324
  type: "module",
2323
2325
  main: "./dist/index.cjs",
@@ -2976,7 +2978,54 @@ async function resolveBrowserData(options = {}) {
2976
2978
  }
2977
2979
  return browserData;
2978
2980
  }
2981
+ function toScreamingSnakeSegment(segment) {
2982
+ return segment.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^A-Za-z0-9]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
2983
+ }
2984
+ function toScreamingSnake(path12) {
2985
+ return path12.split(".").map((segment) => toScreamingSnakeSegment(segment)).filter(Boolean).join("_");
2986
+ }
2987
+ function stripPublicNamespace(key) {
2988
+ return key.startsWith("public.") ? key.slice("public.".length) : key;
2989
+ }
2990
+ function resolveFrameworkPrefix(framework, prefix) {
2991
+ if (prefix !== void 0) {
2992
+ return prefix;
2993
+ }
2994
+ switch (framework) {
2995
+ case "vite":
2996
+ return "VITE_";
2997
+ case "next":
2998
+ return "NEXT_PUBLIC_";
2999
+ case "webpack":
3000
+ case "generic":
3001
+ return "";
3002
+ default:
3003
+ return "";
3004
+ }
3005
+ }
3006
+ function toFrameworkEnv(browserData, framework = "generic", options = {}) {
3007
+ const resolvedPrefix = resolveFrameworkPrefix(framework, options.prefix);
3008
+ return Object.fromEntries(
3009
+ Object.entries(browserData).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => [
3010
+ `${resolvedPrefix}${toScreamingSnake(stripPublicNamespace(key))}`,
3011
+ String(value)
3012
+ ])
3013
+ );
3014
+ }
3015
+ async function resolveFrameworkEnv(options = {}, framework = "generic", envOptions = {}) {
3016
+ if (framework === "generic") {
3017
+ const browserData = await resolveBrowserData(options);
3018
+ return toFrameworkEnv(browserData, framework, envOptions);
3019
+ }
3020
+ const runtime = await createCnos2(options);
3021
+ return runtime.toPublicEnv({
3022
+ framework,
3023
+ ...envOptions.prefix ? { prefix: envOptions.prefix } : {}
3024
+ });
3025
+ }
2979
3026
  // Annotate the CommonJS export names for ESM import in node:
2980
3027
  0 && (module.exports = {
2981
- resolveBrowserData
3028
+ resolveBrowserData,
3029
+ resolveFrameworkEnv,
3030
+ toFrameworkEnv
2982
3031
  });
@@ -1,5 +1,13 @@
1
1
  import { C as CnosCreateOptions } from '../plugin-B4xwySxw.cjs';
2
2
 
3
- declare function resolveBrowserData(options?: CnosCreateOptions): Promise<Record<string, unknown>>;
3
+ type BrowserDataMap = Record<string, unknown>;
4
+ type FrameworkEnvTarget = 'generic' | 'vite' | 'next' | 'webpack' | (string & {});
5
+ declare function resolveBrowserData(options?: CnosCreateOptions): Promise<BrowserDataMap>;
6
+ declare function toFrameworkEnv(browserData: BrowserDataMap, framework?: FrameworkEnvTarget, options?: {
7
+ prefix?: string;
8
+ }): Record<string, string>;
9
+ declare function resolveFrameworkEnv(options?: CnosCreateOptions, framework?: FrameworkEnvTarget, envOptions?: {
10
+ prefix?: string;
11
+ }): Promise<Record<string, string>>;
4
12
 
5
- export { resolveBrowserData };
13
+ export { type BrowserDataMap, type FrameworkEnvTarget, resolveBrowserData, resolveFrameworkEnv, toFrameworkEnv };
@@ -1,5 +1,13 @@
1
1
  import { C as CnosCreateOptions } from '../plugin-B4xwySxw.js';
2
2
 
3
- declare function resolveBrowserData(options?: CnosCreateOptions): Promise<Record<string, unknown>>;
3
+ type BrowserDataMap = Record<string, unknown>;
4
+ type FrameworkEnvTarget = 'generic' | 'vite' | 'next' | 'webpack' | (string & {});
5
+ declare function resolveBrowserData(options?: CnosCreateOptions): Promise<BrowserDataMap>;
6
+ declare function toFrameworkEnv(browserData: BrowserDataMap, framework?: FrameworkEnvTarget, options?: {
7
+ prefix?: string;
8
+ }): Record<string, string>;
9
+ declare function resolveFrameworkEnv(options?: CnosCreateOptions, framework?: FrameworkEnvTarget, envOptions?: {
10
+ prefix?: string;
11
+ }): Promise<Record<string, string>>;
4
12
 
5
- export { resolveBrowserData };
13
+ export { type BrowserDataMap, type FrameworkEnvTarget, resolveBrowserData, resolveFrameworkEnv, toFrameworkEnv };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createCnos
3
- } from "../chunk-JSBVYK2T.js";
3
+ } from "../chunk-RYGSG3GR.js";
4
4
  import "../chunk-J4K4JUJL.js";
5
5
  import "../chunk-T6Y57KTT.js";
6
6
  import "../chunk-WCHX2QFY.js";
@@ -21,6 +21,53 @@ async function resolveBrowserData(options = {}) {
21
21
  }
22
22
  return browserData;
23
23
  }
24
+ function toScreamingSnakeSegment(segment) {
25
+ return segment.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^A-Za-z0-9]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
26
+ }
27
+ function toScreamingSnake(path) {
28
+ return path.split(".").map((segment) => toScreamingSnakeSegment(segment)).filter(Boolean).join("_");
29
+ }
30
+ function stripPublicNamespace(key) {
31
+ return key.startsWith("public.") ? key.slice("public.".length) : key;
32
+ }
33
+ function resolveFrameworkPrefix(framework, prefix) {
34
+ if (prefix !== void 0) {
35
+ return prefix;
36
+ }
37
+ switch (framework) {
38
+ case "vite":
39
+ return "VITE_";
40
+ case "next":
41
+ return "NEXT_PUBLIC_";
42
+ case "webpack":
43
+ case "generic":
44
+ return "";
45
+ default:
46
+ return "";
47
+ }
48
+ }
49
+ function toFrameworkEnv(browserData, framework = "generic", options = {}) {
50
+ const resolvedPrefix = resolveFrameworkPrefix(framework, options.prefix);
51
+ return Object.fromEntries(
52
+ Object.entries(browserData).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => [
53
+ `${resolvedPrefix}${toScreamingSnake(stripPublicNamespace(key))}`,
54
+ String(value)
55
+ ])
56
+ );
57
+ }
58
+ async function resolveFrameworkEnv(options = {}, framework = "generic", envOptions = {}) {
59
+ if (framework === "generic") {
60
+ const browserData = await resolveBrowserData(options);
61
+ return toFrameworkEnv(browserData, framework, envOptions);
62
+ }
63
+ const runtime = await createCnos(options);
64
+ return runtime.toPublicEnv({
65
+ framework,
66
+ ...envOptions.prefix ? { prefix: envOptions.prefix } : {}
67
+ });
68
+ }
24
69
  export {
25
- resolveBrowserData
70
+ resolveBrowserData,
71
+ resolveFrameworkEnv,
72
+ toFrameworkEnv
26
73
  };
@@ -68,7 +68,7 @@ function setBootstrappedSecretHydrationRequired(value) {
68
68
  // package.json
69
69
  var package_default = {
70
70
  name: "@kitsy/cnos",
71
- version: "1.4.0",
71
+ version: "1.5.0",
72
72
  description: "Batteries-included CNOS runtime package wired with the official plugins.",
73
73
  type: "module",
74
74
  main: "./dist/index.cjs",
@@ -10,7 +10,7 @@ import {
10
10
  setBootstrappedSecretHydrationRequired,
11
11
  setSingletonReady,
12
12
  setSingletonRuntime
13
- } from "./chunk-JSBVYK2T.js";
13
+ } from "./chunk-RYGSG3GR.js";
14
14
  import {
15
15
  inspectValue,
16
16
  readOrValue,
@@ -2364,7 +2364,7 @@ function envVarToLogicalKey(envVar, config = {}) {
2364
2364
  // package.json
2365
2365
  var package_default = {
2366
2366
  name: "@kitsy/cnos",
2367
- version: "1.4.0",
2367
+ version: "1.5.0",
2368
2368
  description: "Batteries-included CNOS runtime package wired with the official plugins.",
2369
2369
  type: "module",
2370
2370
  main: "./dist/index.cjs",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createCnos,
3
3
  defaultPlugins
4
- } from "../chunk-JSBVYK2T.js";
4
+ } from "../chunk-RYGSG3GR.js";
5
5
  import "../chunk-J4K4JUJL.js";
6
6
  import "../chunk-T6Y57KTT.js";
7
7
  import "../chunk-WCHX2QFY.js";
package/dist/index.cjs CHANGED
@@ -2318,7 +2318,7 @@ function envVarToLogicalKey(envVar, config = {}) {
2318
2318
  // package.json
2319
2319
  var package_default = {
2320
2320
  name: "@kitsy/cnos",
2321
- version: "1.4.0",
2321
+ version: "1.5.0",
2322
2322
  description: "Batteries-included CNOS runtime package wired with the official plugins.",
2323
2323
  type: "module",
2324
2324
  main: "./dist/index.cjs",
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runtime_default
3
- } from "./chunk-LJD4SM32.js";
3
+ } from "./chunk-TO76YYS4.js";
4
4
  import "./chunk-EQSKV3DP.js";
5
- import "./chunk-JSBVYK2T.js";
5
+ import "./chunk-RYGSG3GR.js";
6
6
  import "./chunk-J4K4JUJL.js";
7
7
  import "./chunk-T6Y57KTT.js";
8
8
  import "./chunk-WCHX2QFY.js";
@@ -2317,7 +2317,7 @@ function envVarToLogicalKey(envVar, config = {}) {
2317
2317
  // package.json
2318
2318
  var package_default = {
2319
2319
  name: "@kitsy/cnos",
2320
- version: "1.4.0",
2320
+ version: "1.5.0",
2321
2321
  description: "Batteries-included CNOS runtime package wired with the official plugins.",
2322
2322
  type: "module",
2323
2323
  main: "./dist/index.cjs",
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runtime_default
3
- } from "../chunk-LJD4SM32.js";
3
+ } from "../chunk-TO76YYS4.js";
4
4
  import "../chunk-EQSKV3DP.js";
5
- import "../chunk-JSBVYK2T.js";
5
+ import "../chunk-RYGSG3GR.js";
6
6
  import "../chunk-J4K4JUJL.js";
7
7
  import "../chunk-T6Y57KTT.js";
8
8
  import "../chunk-WCHX2QFY.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitsy/cnos",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Batteries-included CNOS runtime package wired with the official plugins.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",