@kitsy/cnos 1.1.2 → 1.2.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.
Files changed (60) hide show
  1. package/README.md +4 -1
  2. package/dist/browser/index.cjs +94 -0
  3. package/dist/browser/index.d.cts +16 -0
  4. package/dist/browser/index.d.ts +16 -0
  5. package/dist/browser/index.js +67 -0
  6. package/dist/build/index.cjs +2100 -0
  7. package/dist/build/index.d.cts +5 -0
  8. package/dist/build/index.d.ts +5 -0
  9. package/dist/build/index.js +14 -0
  10. package/dist/{chunk-33ZDYDQJ.js → chunk-APCTXRUN.js} +550 -349
  11. package/dist/{chunk-IHSV5AFX.js → chunk-EIN55XXA.js} +1 -1
  12. package/dist/chunk-JUHPBAEH.js +20 -0
  13. package/dist/{chunk-JQGGSNCL.js → chunk-MLQGYCO7.js} +1 -1
  14. package/dist/chunk-PQ4KSV76.js +50 -0
  15. package/dist/{chunk-IQOUWY6T.js → chunk-RD5WMHPM.js} +1 -1
  16. package/dist/chunk-SO5XREEU.js +179 -0
  17. package/dist/{chunk-7FBRVJD6.js → chunk-SXTMTACL.js} +2 -2
  18. package/dist/{chunk-53HXUSM6.js → chunk-WHUGFPE4.js} +1 -1
  19. package/dist/{chunk-HOS4E7XO.js → chunk-ZA74BO47.js} +1 -1
  20. package/dist/{envNaming-BrOk5ndZ.d.cts → envNaming-BTJpH93W.d.cts} +1 -1
  21. package/dist/{envNaming-DCaNdnrF.d.ts → envNaming-CcsqAel3.d.ts} +1 -1
  22. package/dist/index.cjs +242 -74
  23. package/dist/index.d.cts +4 -3
  24. package/dist/index.d.ts +4 -3
  25. package/dist/index.js +14 -132
  26. package/dist/internal.cjs +428 -10
  27. package/dist/internal.d.cts +29 -3
  28. package/dist/internal.d.ts +29 -3
  29. package/dist/internal.js +27 -1
  30. package/dist/plugin/basic-schema.d.cts +1 -1
  31. package/dist/plugin/basic-schema.d.ts +1 -1
  32. package/dist/plugin/basic-schema.js +2 -2
  33. package/dist/plugin/cli-args.d.cts +1 -1
  34. package/dist/plugin/cli-args.d.ts +1 -1
  35. package/dist/plugin/cli-args.js +2 -2
  36. package/dist/plugin/dotenv.cjs +4 -4
  37. package/dist/plugin/dotenv.d.cts +2 -2
  38. package/dist/plugin/dotenv.d.ts +2 -2
  39. package/dist/plugin/dotenv.js +2 -2
  40. package/dist/plugin/env-export.cjs +29 -46
  41. package/dist/plugin/env-export.d.cts +2 -2
  42. package/dist/plugin/env-export.d.ts +2 -2
  43. package/dist/plugin/env-export.js +2 -2
  44. package/dist/plugin/filesystem.cjs +1 -1
  45. package/dist/plugin/filesystem.d.cts +1 -1
  46. package/dist/plugin/filesystem.d.ts +1 -1
  47. package/dist/plugin/filesystem.js +2 -2
  48. package/dist/plugin/process-env.cjs +4 -4
  49. package/dist/plugin/process-env.d.cts +2 -2
  50. package/dist/plugin/process-env.d.ts +2 -2
  51. package/dist/plugin/process-env.js +2 -2
  52. package/dist/{plugin-BVNEHj19.d.cts → plugin-DkOIT5uI.d.cts} +30 -2
  53. package/dist/{plugin-BVNEHj19.d.ts → plugin-DkOIT5uI.d.ts} +30 -2
  54. package/dist/runtime/index.cjs +2288 -0
  55. package/dist/runtime/index.d.cts +23 -0
  56. package/dist/runtime/index.d.ts +23 -0
  57. package/dist/runtime/index.js +190 -0
  58. package/dist/{toPublicEnv-Gwz3xTK0.d.ts → toPublicEnv-C9clvXLo.d.ts} +1 -1
  59. package/dist/{toPublicEnv-Dd152fFy.d.cts → toPublicEnv-DvFeV3qG.d.cts} +1 -1
  60. package/package.json +16 -1
package/README.md CHANGED
@@ -4,6 +4,9 @@ Developer-friendly CNOS runtime assembly. It bundles the core engine plus the of
4
4
 
5
5
  Current runtime surface includes:
6
6
  - `createCnos()`
7
+ - `@kitsy/cnos/runtime` singleton with `cnos(key)` and `ready()`
8
+ - `@kitsy/cnos/browser` for promoted `public.*` reads in browser code
9
+ - `@kitsy/cnos/build` with `resolveBrowserData()`
7
10
  - `read`, `require`, `readOr`
8
11
  - `value`, `secret`, `meta`
9
12
  - `inspect`
@@ -16,4 +19,4 @@ CLI-oriented storage/export rules to be aware of:
16
19
  - shell env export comes from explicit `envMapping.explicit`
17
20
  - local secret material lives outside the repo in encrypted vault storage under `~/.cnos/secrets`
18
21
 
19
- 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.
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`.
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/browser/index.ts
21
+ var browser_exports = {};
22
+ __export(browser_exports, {
23
+ default: () => browser_default,
24
+ read: () => read,
25
+ require: () => require2,
26
+ toObject: () => toObject
27
+ });
28
+ module.exports = __toCommonJS(browser_exports);
29
+ var SECRET_ACCESS_MESSAGE = "CNOS: secret.* keys are not available in the browser.";
30
+ function readEmbeddedSource() {
31
+ const globalSource = globalThis.__CNOS_BROWSER_DATA__;
32
+ if (globalSource !== void 0) {
33
+ return globalSource;
34
+ }
35
+ if (typeof process !== "undefined") {
36
+ return process.env?.__CNOS_BROWSER_DATA__;
37
+ }
38
+ return void 0;
39
+ }
40
+ function parseBrowserData(source) {
41
+ if (source === void 0 || source === null || source === "") {
42
+ return {};
43
+ }
44
+ if (typeof source === "string") {
45
+ const parsed = JSON.parse(source);
46
+ return parseBrowserData(parsed);
47
+ }
48
+ if (typeof source === "object" && !Array.isArray(source)) {
49
+ return { ...source };
50
+ }
51
+ return {};
52
+ }
53
+ function normalizeBrowserKey(key) {
54
+ if (key.startsWith("secret.")) {
55
+ throw new Error(SECRET_ACCESS_MESSAGE);
56
+ }
57
+ if (key.startsWith("public.")) {
58
+ return key;
59
+ }
60
+ if (key.startsWith("value.")) {
61
+ return `public.${key.slice("value.".length)}`;
62
+ }
63
+ return `public.${key}`;
64
+ }
65
+ function read(key) {
66
+ const normalized = normalizeBrowserKey(key);
67
+ const data = parseBrowserData(readEmbeddedSource());
68
+ return data[normalized];
69
+ }
70
+ function require2(key) {
71
+ const value = read(key);
72
+ if (value === void 0) {
73
+ throw new Error(`CNOS: key "${key}" not found in browser config.`);
74
+ }
75
+ return value;
76
+ }
77
+ function toObject() {
78
+ return parseBrowserData(readEmbeddedSource());
79
+ }
80
+ var cnos = Object.assign(
81
+ ((key) => read(key)),
82
+ {
83
+ read,
84
+ require: require2,
85
+ toObject
86
+ }
87
+ );
88
+ var browser_default = cnos;
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {
91
+ read,
92
+ require,
93
+ toObject
94
+ });
@@ -0,0 +1,16 @@
1
+ interface BrowserCnosRuntime {
2
+ <T = unknown>(key: string): T | undefined;
3
+ read<T = unknown>(key: string): T | undefined;
4
+ require<T = unknown>(key: string): T;
5
+ toObject(): Record<string, unknown>;
6
+ }
7
+ declare function read<T = unknown>(key: string): T | undefined;
8
+ declare function require$1<T = unknown>(key: string): T;
9
+ declare function toObject(): Record<string, unknown>;
10
+ declare const cnos: BrowserCnosRuntime & {
11
+ read: typeof read;
12
+ require: typeof require$1;
13
+ toObject: typeof toObject;
14
+ };
15
+
16
+ export { type BrowserCnosRuntime, cnos as default, read, require$1 as require, toObject };
@@ -0,0 +1,16 @@
1
+ interface BrowserCnosRuntime {
2
+ <T = unknown>(key: string): T | undefined;
3
+ read<T = unknown>(key: string): T | undefined;
4
+ require<T = unknown>(key: string): T;
5
+ toObject(): Record<string, unknown>;
6
+ }
7
+ declare function read<T = unknown>(key: string): T | undefined;
8
+ declare function require$1<T = unknown>(key: string): T;
9
+ declare function toObject(): Record<string, unknown>;
10
+ declare const cnos: BrowserCnosRuntime & {
11
+ read: typeof read;
12
+ require: typeof require$1;
13
+ toObject: typeof toObject;
14
+ };
15
+
16
+ export { type BrowserCnosRuntime, cnos as default, read, require$1 as require, toObject };
@@ -0,0 +1,67 @@
1
+ // src/browser/index.ts
2
+ var SECRET_ACCESS_MESSAGE = "CNOS: secret.* keys are not available in the browser.";
3
+ function readEmbeddedSource() {
4
+ const globalSource = globalThis.__CNOS_BROWSER_DATA__;
5
+ if (globalSource !== void 0) {
6
+ return globalSource;
7
+ }
8
+ if (typeof process !== "undefined") {
9
+ return process.env?.__CNOS_BROWSER_DATA__;
10
+ }
11
+ return void 0;
12
+ }
13
+ function parseBrowserData(source) {
14
+ if (source === void 0 || source === null || source === "") {
15
+ return {};
16
+ }
17
+ if (typeof source === "string") {
18
+ const parsed = JSON.parse(source);
19
+ return parseBrowserData(parsed);
20
+ }
21
+ if (typeof source === "object" && !Array.isArray(source)) {
22
+ return { ...source };
23
+ }
24
+ return {};
25
+ }
26
+ function normalizeBrowserKey(key) {
27
+ if (key.startsWith("secret.")) {
28
+ throw new Error(SECRET_ACCESS_MESSAGE);
29
+ }
30
+ if (key.startsWith("public.")) {
31
+ return key;
32
+ }
33
+ if (key.startsWith("value.")) {
34
+ return `public.${key.slice("value.".length)}`;
35
+ }
36
+ return `public.${key}`;
37
+ }
38
+ function read(key) {
39
+ const normalized = normalizeBrowserKey(key);
40
+ const data = parseBrowserData(readEmbeddedSource());
41
+ return data[normalized];
42
+ }
43
+ function require2(key) {
44
+ const value = read(key);
45
+ if (value === void 0) {
46
+ throw new Error(`CNOS: key "${key}" not found in browser config.`);
47
+ }
48
+ return value;
49
+ }
50
+ function toObject() {
51
+ return parseBrowserData(readEmbeddedSource());
52
+ }
53
+ var cnos = Object.assign(
54
+ ((key) => read(key)),
55
+ {
56
+ read,
57
+ require: require2,
58
+ toObject
59
+ }
60
+ );
61
+ var browser_default = cnos;
62
+ export {
63
+ browser_default as default,
64
+ read,
65
+ require2 as require,
66
+ toObject
67
+ };