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