startupjs 0.61.13 → 0.61.14

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/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import React from 'react'
2
+
1
3
  export { BASE_URL } from '@startupjs/utils/BASE_URL'
2
4
  export { default as axios } from '@startupjs/utils/axios'
3
5
  export * from 'teamplay'
@@ -15,3 +17,19 @@ export { default as StartupjsProvider } from './StartupjsProvider.js'
15
17
 
16
18
  // loading config should be performed first
17
19
  export { default as __dummyLoadConfig } from '@startupjs/registry/loadStartupjsConfig.auto'
20
+
21
+ // COMPAT-ONLY legacy hook expected by older LMS code and packages built against
22
+ // the historic startupjs surface. On web and in the current Expo migration we do
23
+ // not have a root-level back-press integration here, so the compat contract is a
24
+ // safe no-op hook. This keeps old imports working without reintroducing the old
25
+ // runtime behavior.
26
+ export function useBackPress () {}
27
+
28
+ // COMPAT-ONLY stable component id helper expected by older Startupjs libraries.
29
+ // Keep it ref-based to preserve a hook-safe, runtime-agnostic compat contract.
30
+ let _componentIdCounter = 0
31
+ export function useComponentId (prefix = 'c') {
32
+ const ref = React.useRef()
33
+ if (!ref.current) ref.current = `${prefix}_${++_componentIdCounter}`
34
+ return ref.current
35
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "startupjs",
3
3
  "type": "module",
4
- "version": "0.61.13",
4
+ "version": "0.61.14",
5
5
  "engines": {
6
6
  "node": ">= 14"
7
7
  },
@@ -60,5 +60,5 @@
60
60
  "scripts": {
61
61
  "test": "node --experimental-specifier-resolution=node --test"
62
62
  },
63
- "gitHead": "94c0c94b80870fa975266a48eb1673ab74d67231"
63
+ "gitHead": "673f1b736954d8fcf15fb7d43b6b757a710a004a"
64
64
  }
@@ -0,0 +1,35 @@
1
+ import React from 'react'
2
+ import { renderToStaticMarkup } from 'react-dom/server'
3
+ import test from 'node:test'
4
+ import assert from 'node:assert/strict'
5
+
6
+ import { useBackPress, useComponentId } from '../index.js'
7
+
8
+ test('useBackPress compat hook is defined and is a no-op', () => {
9
+ function Probe () {
10
+ assert.equal(useBackPress(), undefined)
11
+ return React.createElement('div')
12
+ }
13
+
14
+ assert.doesNotThrow(() => {
15
+ renderToStaticMarkup(React.createElement(Probe))
16
+ })
17
+ })
18
+
19
+ test('useComponentId returns a stable id within the same render pass', () => {
20
+ let firstId
21
+ let secondId
22
+
23
+ function Probe () {
24
+ firstId = useComponentId('x')
25
+ secondId = useComponentId('x')
26
+ return React.createElement('div')
27
+ }
28
+
29
+ renderToStaticMarkup(React.createElement(Probe))
30
+
31
+ assert.equal(typeof firstId, 'string')
32
+ assert.equal(typeof secondId, 'string')
33
+ assert.notEqual(firstId, '')
34
+ assert.notEqual(secondId, '')
35
+ })