@sbc-connect/nuxt-base 0.7.2 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @sbc-connect/nuxt-base
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#158](https://github.com/bcgov/connect-nuxt/pull/158) [`fe5065e`](https://github.com/bcgov/connect-nuxt/commit/fe5065e12d776349e7093e52ecee51ce22a2c271) Thanks [@vysakh-menon-aot](https://github.com/vysakh-menon-aot)! - Switch LD dependency to js-client-sdk
8
+
9
+ ## 0.7.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#155](https://github.com/bcgov/connect-nuxt/pull/155) [`e4ad236`](https://github.com/bcgov/connect-nuxt/commit/e4ad2360c255173e20b7f6d384de2a9313ce747d) Thanks [@deetz99](https://github.com/deetz99)! - Custom CSS classes for x and xy default padding and left error border for container elements.
14
+
3
15
  ## 0.7.2
4
16
 
5
17
  ### Patch Changes
@@ -90,9 +90,10 @@
90
90
  --marker-upper-alpha: upper-alpha;
91
91
 
92
92
  /* box shadow */
93
- --shadow-input: inset 0 -1px 0 0px var(--ui-neutral);
94
- --shadow-input-focus: inset 0 -2px 0 0px var(--ui-primary);
95
- --shadow-input-error: inset 0 -2px 0 0px var(--ui-error);
93
+ /* bottom neutral/focused/error border for input elements */
94
+ --shadow-input: inset 0 -1px 0 0 var(--ui-neutral);
95
+ --shadow-input-focus: inset 0 -2px 0 0 var(--ui-primary);
96
+ --shadow-input-error: inset 0 -2px 0 0 var(--ui-error);
96
97
 
97
98
  /* GRAY */
98
99
  --color-gray-50: #f8f9fa;
@@ -274,4 +275,29 @@ body {
274
275
  .floating-label-textarea {
275
276
  @apply pointer-events-none absolute left-0 top-1 text-neutral text-xs font-medium px-2.5 transition-all duration-200 peer-focus:top-1 peer-focus:text-xs peer-placeholder-shown:text-sm peer-placeholder-shown:top-2.5 peer-focus:translate-none peer-focus:text-primary peer-aria-invalid:text-error;
276
277
  }
278
+
279
+ /* Standard container padding */
280
+ .padding-x-default {
281
+ @apply px-4 sm:px-7.5
282
+ }
283
+
284
+ .padding-xy-default {
285
+ @apply py-6 px-4 sm:py-10 sm:px-7.5
286
+ }
287
+
288
+ /* left error border for section elements */
289
+ /* Psuedo element required to be visible so slot content does not cover it */
290
+ .shadow-section-error {
291
+ position: relative;
292
+ }
293
+
294
+ .shadow-section-error::before {
295
+ content: "";
296
+ position: absolute;
297
+ inset: 0 auto 0 0;
298
+ width: 3px;
299
+ background-color: var(--ui-error);
300
+ pointer-events: none;
301
+ z-index: 1;
302
+ }
277
303
  }
@@ -1,69 +1,72 @@
1
- import { initialize } from 'launchdarkly-js-client-sdk'
2
- import type { LDClient, LDFlagSet, LDOptions, LDContext } from 'launchdarkly-js-client-sdk'
3
-
4
- // state
5
- // Defined outside of composable, so they are created only once and shared
6
- const ldClient = shallowRef<LDClient | null>(null)
7
- const ldFlagSet = shallowRef<LDFlagSet>({})
8
- const ldInitialized = ref(false)
9
- const isInitializing = ref(false)
1
+ import { createClient } from '@launchdarkly/js-client-sdk'
2
+ import type { LDClient, LDFlagSet, LDOptions, LDContext } from '@launchdarkly/js-client-sdk'
10
3
 
11
4
  /**
12
- * Initializes the LaunchDarkly client with an anonymous context.
13
- */
14
- function init(): void {
15
- const rtc = useRuntimeConfig().public
16
-
17
- // Prevent re-initialization
18
- if (ldInitialized.value || isInitializing.value) {
19
- return
20
- }
21
- // Prevent initialization if missing client ID
22
- if (!rtc.ldClientId) {
23
- console.error('LaunchDarkly: ldClientId is not configured.')
24
- return
25
- }
5
+ * Composable for the LaunchDarkly service.
6
+ */
7
+ export const useConnectLaunchDarkly = () => {
8
+ const ldClient = useState<LDClient | null>('ld-client', () => null)
9
+ const ldFlagSet = useState<LDFlagSet>('ld-flag-set', () => ({}))
10
+ const ldInitialized = useState<boolean>('ld-initialized', () => false)
11
+ const isInitializing = useState<boolean>('ld-is-initializing', () => false)
26
12
 
27
- isInitializing.value = true
13
+ /**
14
+ * Initializes the LaunchDarkly client with an anonymous context.
15
+ */
16
+ function init(): void {
17
+ const rtc = useRuntimeConfig().public
28
18
 
29
- const ldContext: LDContext = {
30
- kind: 'user',
31
- key: 'anonymous',
32
- anonymous: true,
33
- appSource: rtc.appName
34
- }
19
+ // Prevent re-initialization
20
+ if (ldInitialized.value || isInitializing.value) {
21
+ return
22
+ }
23
+ // Prevent initialization if missing client ID
24
+ if (!rtc.ldClientId) {
25
+ console.error('LaunchDarkly: ldClientId is not configured.')
26
+ return
27
+ }
35
28
 
36
- const options: LDOptions = {
37
- streaming: false,
38
- useReport: false,
39
- diagnosticOptOut: true
40
- }
29
+ isInitializing.value = true
41
30
 
42
- try {
43
- ldClient.value = initialize(rtc.ldClientId, ldContext, options)
31
+ const ldContext: LDContext = {
32
+ kind: 'user',
33
+ key: 'anonymous',
34
+ anonymous: true,
35
+ appSource: rtc.appName
36
+ }
44
37
 
45
- ldClient.value.on('initialized', () => {
46
- ldFlagSet.value = ldClient.value?.allFlags() || {}
47
- ldInitialized.value = true
48
- isInitializing.value = false
49
- console.info('LaunchDarkly: Anonymous initialization complete.')
50
- })
38
+ const options: LDOptions = {
39
+ streaming: false,
40
+ useReport: false,
41
+ diagnosticOptOut: true
42
+ }
51
43
 
52
- ldClient.value.on('error', (error) => {
53
- console.error('LaunchDarkly: Initialization error.', error)
44
+ try {
45
+ const client = createClient(rtc.ldClientId, ldContext, options)
46
+
47
+ client.start().then((result) => {
48
+ if (result.status === 'complete') {
49
+ ldFlagSet.value = client.allFlags()
50
+ ldInitialized.value = true
51
+ isInitializing.value = false
52
+ console.info('LaunchDarkly: Anonymous initialization complete.')
53
+ } else {
54
+ console.error('LaunchDarkly: Initialization did not complete.', result)
55
+ isInitializing.value = false
56
+ }
57
+ }).catch((error) => {
58
+ console.error('LaunchDarkly: Initialization error.', error)
59
+ isInitializing.value = false
60
+ })
61
+
62
+ ldClient.value = client
63
+ } catch (error) {
64
+ console.error('LaunchDarkly: Failed to initialize.', error)
54
65
  isInitializing.value = false
55
- })
56
- } catch (error) {
57
- console.error('LaunchDarkly: Failed to initialize.', error)
58
- isInitializing.value = false
66
+ }
59
67
  }
60
- }
61
68
 
62
- /**
63
- * Composable for the LaunchDarkly service.
64
- */
65
- export const useConnectLaunchDarkly = () => {
66
- // initialize only once
69
+ // Initialize only once on the client
67
70
  if (!ldInitialized.value && !isInitializing.value && import.meta.client) {
68
71
  init()
69
72
  }
@@ -95,12 +98,12 @@ export const useConnectLaunchDarkly = () => {
95
98
  if (!ldClient.value) {
96
99
  return Promise.resolve(defaultValue)
97
100
  }
98
- return ldClient.value.waitUntilReady()
99
- .then(() => ldClient.value ? ldClient.value.variation(name, defaultValue) : defaultValue)
100
- .catch((error) => {
101
- console.error(`LaunchDarkly: Error waiting for client while getting flag "${name}".`, error)
102
- return defaultValue
103
- })
101
+ return ldClient.value.waitForInitialization().then(() =>
102
+ ldClient.value ? ldClient.value.variation(name, defaultValue) : defaultValue
103
+ ).catch((error) => {
104
+ console.error(`LaunchDarkly: Error waiting for client while getting flag "${name}".`, error)
105
+ return defaultValue
106
+ })
104
107
  }
105
108
 
106
109
  // reactive mode
@@ -131,12 +134,12 @@ export const useConnectLaunchDarkly = () => {
131
134
  if (!ldClient.value) {
132
135
  return Promise.resolve(defaultValue)
133
136
  }
134
- return ldClient.value.waitUntilReady()
135
- .then(() => ldFlagSet.value[name] ?? defaultValue)
136
- .catch((error) => {
137
- console.error(`LaunchDarkly: Error waiting for client while getting stored flag "${name}".`, error)
138
- return defaultValue
139
- })
137
+ return ldClient.value.waitForInitialization().then(() =>
138
+ ldFlagSet.value[name] ?? defaultValue
139
+ ).catch((error) => {
140
+ console.error(`LaunchDarkly: Error waiting for client while getting stored flag "${name}".`, error)
141
+ return defaultValue
142
+ })
140
143
  }
141
144
 
142
145
  // reactive mode
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sbc-connect/nuxt-base",
3
3
  "type": "module",
4
- "version": "0.7.2",
4
+ "version": "0.8.0",
5
5
  "repository": "github:bcgov/connect-nuxt",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "./nuxt.config.ts",
@@ -13,7 +13,7 @@
13
13
  "@vueuse/nuxt": "14.2.1",
14
14
  "dompurify": "3.3.3",
15
15
  "es-toolkit": "1.45.1",
16
- "launchdarkly-vue-client-sdk": "2.5.0",
16
+ "@launchdarkly/js-client-sdk": "4.6.5",
17
17
  "luxon": "3.7.2",
18
18
  "maska": "3.2.0",
19
19
  "zod": "4.3.6"
@@ -25,8 +25,8 @@
25
25
  "nuxt": "4.2.2",
26
26
  "typescript": "5.9.3",
27
27
  "vue-tsc": "3.2.5",
28
- "@sbc-connect/eslint-config": "0.0.8",
29
28
  "@sbc-connect/playwright-config": "0.1.1",
29
+ "@sbc-connect/eslint-config": "0.0.8",
30
30
  "@sbc-connect/vitest-config": "0.1.1"
31
31
  },
32
32
  "scripts": {