startupjs 0.61.12 → 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 +18 -0
- package/orm.js +20 -0
- package/package.json +3 -2
- package/test/index.compat.test.js +35 -0
- package/test/orm.test.js +14 -0
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/orm.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COMPAT-ONLY legacy entrypoint for older code and third-party LMS packages
|
|
3
|
+
* which still import model helpers from `startupjs/orm`.
|
|
4
|
+
*
|
|
5
|
+
* Purpose:
|
|
6
|
+
* - preserve the historic import path while the new Startupjs package surface is
|
|
7
|
+
* organized around `startupjs` root exports
|
|
8
|
+
* - avoid mechanical divergence in downstream apps and patched dependencies
|
|
9
|
+
*
|
|
10
|
+
* Contract in this compat file:
|
|
11
|
+
* - `BaseModel` is exposed as an alias of the current `Signal` export
|
|
12
|
+
* - `hasMany` and `belongsTo` are re-exported from the current root package API
|
|
13
|
+
*
|
|
14
|
+
* Explicit limitations:
|
|
15
|
+
* - this file is internal compat support and is intentionally not part of the
|
|
16
|
+
* main documented Startupjs API surface
|
|
17
|
+
* - it only restores the legacy `startupjs/orm` surface used by the LMS stack
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export { Signal as BaseModel, hasMany, belongsTo } from './index.js'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "startupjs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.61.
|
|
4
|
+
"version": "0.61.14",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">= 14"
|
|
7
7
|
},
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"exports": {
|
|
11
11
|
".": "./index.js",
|
|
12
12
|
"./app": "./app.js",
|
|
13
|
+
"./orm": "./orm.js",
|
|
13
14
|
"./auth": "./auth.js",
|
|
14
15
|
"./server": "./server.js",
|
|
15
16
|
"./schema": "./schema.js",
|
|
@@ -59,5 +60,5 @@
|
|
|
59
60
|
"scripts": {
|
|
60
61
|
"test": "node --experimental-specifier-resolution=node --test"
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "673f1b736954d8fcf15fb7d43b6b757a710a004a"
|
|
63
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
|
+
})
|
package/test/orm.test.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
4
|
+
import { Signal, hasMany, belongsTo } from '../index.js'
|
|
5
|
+
import { BaseModel, hasMany as ormHasMany, belongsTo as ormBelongsTo } from '../orm.js'
|
|
6
|
+
|
|
7
|
+
test('startupjs/orm exposes BaseModel as Signal', () => {
|
|
8
|
+
assert.equal(BaseModel, Signal)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test('startupjs/orm re-exports relation helpers', () => {
|
|
12
|
+
assert.equal(ormHasMany, hasMany)
|
|
13
|
+
assert.equal(ormBelongsTo, belongsTo)
|
|
14
|
+
})
|