dazscript-framework 1.0.36 → 1.0.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dazscript-framework",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "author": "Freddy Diaz",
5
5
  "license": "MPL-2.0",
6
6
  "description": "",
@@ -0,0 +1,29 @@
1
+ import { describe, expect, it, vi } from 'vitest'
2
+ import { isHairType } from './node-helper'
3
+
4
+ const getTypeForNode = vi.fn()
5
+ const isHairTypeAsset = vi.fn()
6
+
7
+ vi.mock('@dsf/core/global', () => ({
8
+ app: {
9
+ getAssetMgr: () => ({
10
+ getTypeForNode,
11
+ isHairType: isHairTypeAsset
12
+ })
13
+ },
14
+ sceneHelper: {}
15
+ }))
16
+
17
+ describe('node helper hair classification', () => {
18
+ it('treats eyelash content types as hair regardless of case', () => {
19
+ getTypeForNode.mockReturnValue('Follower/Attachment/Head/Face/Eyelashes')
20
+ isHairTypeAsset.mockReturnValue(false)
21
+
22
+ const node = {
23
+ iskindof: (type: string) => type === 'DzSkeleton',
24
+ getSkeleton: () => node
25
+ }
26
+
27
+ expect(isHairType(node as unknown as DzNode)).toBe(true)
28
+ })
29
+ })
@@ -120,7 +120,7 @@ export const isHairType = (node: DzNode): boolean => {
120
120
  const figure = getFigure(node)!
121
121
  const assetMgr = app.getAssetMgr()
122
122
  const type = assetMgr.getTypeForNode(figure)
123
- return assetMgr.isHairType(type) || contains(type.valueOf(), 'Hair')
123
+ return assetMgr.isHairType(type) || contains(type.valueOf(), ['Hair', 'Eyelashes'], true)
124
124
  }
125
125
 
126
126
  export const isGeoShell = (node: DzNode): boolean => {
@@ -0,0 +1,12 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { contains } from './string-helper'
3
+
4
+ describe('string contains helper', () => {
5
+ it('matches any requested token case-insensitively when requested', () => {
6
+ expect(contains('Follower/Attachment/Head/Face/Eyelashes', ['hair', 'eyelashes'], true)).toBe(true)
7
+ })
8
+
9
+ it('keeps matching case-sensitive by default', () => {
10
+ expect(contains('Follower/Attachment/Head/Face/Eyelashes', 'eyelashes')).toBe(false)
11
+ })
12
+ })
@@ -4,7 +4,17 @@ export const isNumeric = (value: string | number): boolean => {
4
4
  !isNaN(Number(value.toString())))
5
5
  }
6
6
 
7
- export const contains = (source: string, search: string | string[]): boolean => {
7
+ export const contains = (source: string, search: string | string[], caseInsensitive: boolean = false): boolean => {
8
+ if (caseInsensitive) {
9
+ source = source.toLowerCase()
10
+ if (Array.isArray(search)) {
11
+ search = search.map(s => s.toLowerCase())
12
+ }
13
+ else {
14
+ search = search.toLowerCase()
15
+ }
16
+ }
17
+
8
18
  if (Array.isArray(search)) {
9
19
  for (const s of search) {
10
20
  if (source.indexOf(s) >= 0) return true