@kitsy/cnos-next 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.
package/dist/index.cjs CHANGED
@@ -25,6 +25,13 @@ __export(index_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(index_exports);
27
27
  var import_cnos = require("@kitsy/cnos");
28
+ function resolveRuntimeOptions(options, phase) {
29
+ const profile = options.profile ?? options.profileFromPhase?.(phase);
30
+ return {
31
+ ...options,
32
+ ...profile ? { profile } : {}
33
+ };
34
+ }
28
35
  async function resolveBaseConfig(config, phase, context) {
29
36
  if (typeof config === "function") {
30
37
  return config(phase, context);
@@ -32,11 +39,7 @@ async function resolveBaseConfig(config, phase, context) {
32
39
  return config;
33
40
  }
34
41
  async function loadCnosNextEnv(options = {}, phase = "phase-production-build") {
35
- const profile = options.profile ?? options.profileFromPhase?.(phase);
36
- const runtime = await (0, import_cnos.createCnos)({
37
- ...options,
38
- ...profile ? { profile } : {}
39
- });
42
+ const runtime = await (0, import_cnos.createCnos)(resolveRuntimeOptions(options, phase));
40
43
  return runtime.toPublicEnv({
41
44
  framework: "next",
42
45
  ...options.prefix ? { prefix: options.prefix } : {}
@@ -44,14 +47,16 @@ async function loadCnosNextEnv(options = {}, phase = "phase-production-build") {
44
47
  }
45
48
  function withCnosNext(config = {}, options = {}) {
46
49
  return async (phase, context) => {
47
- const [baseConfig, publicEnv] = await Promise.all([
50
+ const [baseConfig, publicEnv, browserData] = await Promise.all([
48
51
  resolveBaseConfig(config, phase, context),
49
- loadCnosNextEnv(options, phase)
52
+ loadCnosNextEnv(options, phase),
53
+ (0, import_cnos.resolveBrowserData)(resolveRuntimeOptions(options, phase))
50
54
  ]);
51
55
  return {
52
56
  ...baseConfig,
53
57
  env: {
54
58
  ...baseConfig.env ?? {},
59
+ __CNOS_BROWSER_DATA__: JSON.stringify(browserData),
55
60
  ...publicEnv
56
61
  }
57
62
  };
package/dist/index.js CHANGED
@@ -1,5 +1,12 @@
1
1
  // src/index.ts
2
- import { createCnos } from "@kitsy/cnos";
2
+ import { createCnos, resolveBrowserData } from "@kitsy/cnos";
3
+ function resolveRuntimeOptions(options, phase) {
4
+ const profile = options.profile ?? options.profileFromPhase?.(phase);
5
+ return {
6
+ ...options,
7
+ ...profile ? { profile } : {}
8
+ };
9
+ }
3
10
  async function resolveBaseConfig(config, phase, context) {
4
11
  if (typeof config === "function") {
5
12
  return config(phase, context);
@@ -7,11 +14,7 @@ async function resolveBaseConfig(config, phase, context) {
7
14
  return config;
8
15
  }
9
16
  async function loadCnosNextEnv(options = {}, phase = "phase-production-build") {
10
- const profile = options.profile ?? options.profileFromPhase?.(phase);
11
- const runtime = await createCnos({
12
- ...options,
13
- ...profile ? { profile } : {}
14
- });
17
+ const runtime = await createCnos(resolveRuntimeOptions(options, phase));
15
18
  return runtime.toPublicEnv({
16
19
  framework: "next",
17
20
  ...options.prefix ? { prefix: options.prefix } : {}
@@ -19,14 +22,16 @@ async function loadCnosNextEnv(options = {}, phase = "phase-production-build") {
19
22
  }
20
23
  function withCnosNext(config = {}, options = {}) {
21
24
  return async (phase, context) => {
22
- const [baseConfig, publicEnv] = await Promise.all([
25
+ const [baseConfig, publicEnv, browserData] = await Promise.all([
23
26
  resolveBaseConfig(config, phase, context),
24
- loadCnosNextEnv(options, phase)
27
+ loadCnosNextEnv(options, phase),
28
+ resolveBrowserData(resolveRuntimeOptions(options, phase))
25
29
  ]);
26
30
  return {
27
31
  ...baseConfig,
28
32
  env: {
29
33
  ...baseConfig.env ?? {},
34
+ __CNOS_BROWSER_DATA__: JSON.stringify(browserData),
30
35
  ...publicEnv
31
36
  }
32
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitsy/cnos-next",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "Next.js integration for CNOS public config injection.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -35,7 +35,7 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@kitsy/cnos": "1.1.2"
38
+ "@kitsy/cnos": "1.2.0"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "next": ">=14"