Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d54d996
fix rename
MinCrohn Jun 24, 2025
8ce7277
fix element schema
MinCrohn Jun 24, 2025
4145942
fix
MinCrohn Jun 24, 2025
db4ebc0
fix schema
MinCrohn Jun 24, 2025
8704b62
fix data.d.ts
MinCrohn Jun 24, 2025
b547489
fix convert
MinCrohn Jun 24, 2025
c08c0cf
fix
MinCrohn Jun 24, 2025
bebf249
update schema
MinCrohn Jun 24, 2025
ed94c28
render
MinCrohn Jun 24, 2025
d4483f1
fix schema
MinCrohn Jun 26, 2025
b00af2d
fix schema test
MinCrohn Jun 26, 2025
daad305
fix jsdoc
MinCrohn Jun 26, 2025
47f1310
add tint type
MinCrohn Jun 26, 2025
eb7e1cb
fix convert func
MinCrohn Jun 26, 2025
9c7a45b
add element class
MinCrohn Jun 30, 2025
140d81b
fix component logic
MinCrohn Jun 30, 2025
fe5fc82
fix item element schema
MinCrohn Jul 1, 2025
51b22fa
fix grid item render
MinCrohn Jul 1, 2025
9c5f58c
fix size schema
MinCrohn Jul 1, 2025
2e96866
fix config management
MinCrohn Jul 1, 2025
a463901
fix get color func
MinCrohn Jul 1, 2025
97900d6
fix relativeTransform
MinCrohn Jul 2, 2025
303adec
apply validate
MinCrohn Jul 2, 2025
6da7c54
fix history
MinCrohn Jul 2, 2025
13b28ee
fix data.d.ts
MinCrohn Jul 2, 2025
667655b
fix Grid updateItem method
MinCrohn Jul 2, 2025
d41761d
update readme
MinCrohn Jul 2, 2025
cd4c10b
fix
MinCrohn Jul 2, 2025
049e20c
update bar size function
MinCrohn Jul 2, 2025
d92d3b5
update size function
MinCrohn Jul 2, 2025
2790221
fix bar-size func
MinCrohn Jul 2, 2025
7b23b40
rename texture-transform
MinCrohn Jul 2, 2025
d7cb774
apply getter/setter
MinCrohn Jul 3, 2025
5adeca0
apply mixin composition architecture
MinCrohn Jul 3, 2025
2666e0f
delete lagecy
MinCrohn Jul 4, 2025
afda740
fix default options
MinCrohn Jul 4, 2025
d25216e
add overwrite
MinCrohn Jul 4, 2025
51143b2
add mixin util
MinCrohn Jul 7, 2025
0f578f5
fix
MinCrohn Jul 7, 2025
06e1e01
fix itemsizeable
MinCrohn Jul 7, 2025
c9d3213
add update overwrite
MinCrohn Jul 7, 2025
8500e2e
fix readme
MinCrohn Jul 7, 2025
11c0b88
fix
MinCrohn Jul 7, 2025
a505812
fix bounds
MinCrohn Jul 7, 2025
bdda73a
chore
MinCrohn Jul 7, 2025
6b116f3
fix get viewport
MinCrohn Jul 7, 2025
cd3c4bc
fix
MinCrohn Jul 7, 2025
f366fb5
fix
MinCrohn Jul 7, 2025
7d779e1
fix Relations
MinCrohn Jul 7, 2025
52a8cb1
chore
MinCrohn Jul 7, 2025
64a256f
fix update
MinCrohn Jul 7, 2025
e89eb8c
add new element & component
MinCrohn Jul 8, 2025
5beec5a
fix circular dependency
MinCrohn Jul 8, 2025
d2c3ea0
fix overwrite
MinCrohn Jul 8, 2025
0443c1f
fix grid mixins
MinCrohn Jul 8, 2025
ca36a32
replace array merge
MinCrohn Jul 8, 2025
dfb8c67
add bottom-up
MinCrohn Jul 9, 2025
f3e7f02
fix source key
MinCrohn Jul 9, 2025
7921a58
init browser test
MinCrohn Jul 10, 2025
881c219
chore
MinCrohn Jul 10, 2025
74e858e
add px or percent size calc
MinCrohn Jul 10, 2025
fca997c
fix icon test
MinCrohn Jul 10, 2025
5ea7678
fix
MinCrohn Jul 10, 2025
c778a09
fix
MinCrohn Jul 14, 2025
ad6fed4
fix findIndexByPriority
MinCrohn Jul 14, 2025
94d5acd
chore
MinCrohn Jul 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 67 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ npm install @conalog/patch-map

#### CDN
```html
<script src="https://cdn.jsdelivr.net/npm/pixi.js@8.9.2/dist/pixi.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@conalog/patch-map@v0.1.9/dist/index.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pixi.js@latest/dist/pixi.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@conalog/patch-map@latest/dist/index.umd.js"></script>
```

### Usage
Expand All @@ -67,27 +67,30 @@ const data = [
type: 'group',
id: 'group-id-1',
label: 'group-label-1',
items: [{
children: [{
type: 'grid',
id: 'grid-1',
label: 'grid-label-1',
cells: [ [1, 0, 1], [1, 1, 1] ],
position: { x: 0, y: 0 },
itemSize: { width: 40, height: 80 },
components: [
{
type: 'background',
texture: {
type: 'rect',
fill: 'white',
borderWidth: 2,
borderColor: 'primary.dark',
radius: 4,
}
},
{ type: 'icon', asset: 'loading', size: 16 }
]
}]
gap: 4,
item: {
size: { width: 40, height: 80 },
components: [
{
type: 'background',
source: {
type: 'rect',
fill: 'white',
borderWidth: 2,
borderColor: 'primary.dark',
radius: 4,
}
},
{ type: 'icon', source: 'loading', tint: 'black', size: 16 },
]
},
}],
attrs: { x: 100, y: 100, },
}
];

Expand Down Expand Up @@ -185,27 +188,30 @@ const data = [
type: 'group',
id: 'group-id-1',
label: 'group-label-1',
items: [{
children: [{
type: 'grid',
id: 'grid-1',
label: 'grid-label-1',
cells: [ [1, 0, 1], [1, 1, 1] ],
position: { x: 0, y: 0 },
itemSize: { width: 40, height: 80 },
components: [
{
type: 'background',
texture: {
type: 'rect',
fill: 'white',
borderWidth: 2,
borderColor: 'primary.dark',
radius: 4,
}
},
{ type: 'icon', asset: 'loading', size: 16 }
]
}]
gap: 4,
item: {
size: { width: 40, height: 80 },
components: [
{
type: 'background',
source: {
type: 'rect',
fill: 'white',
borderWidth: 2,
borderColor: 'primary.dark',
radius: 4,
}
},
{ type: 'icon', source: 'loading', tint: 'black', size: 16 },
]
},
}],
attrs: { x: 100, y: 100, },
}
];
patchmap.draw(data);
Expand All @@ -220,24 +226,29 @@ For **detailed type definitions**, refer to the [data.d.ts](src/display/data-sch
<br/>

### `update(options)`
Updates the state of specific objects on the canvas. Use this to change properties like color or text visibility for already rendered objects.
Updates the properties of objects rendered on the canvas. By default, only the changed properties are applied, but you can precisely control the update behavior using the `refresh` or `arrayMerge` options.

#### **`Options`**
- `path`(optional, string) - Selector for the object to which the event will be applied, following [jsonpath](https://github.com/JSONPath-Plus/JSONPath) syntax.
- `elements`(optional, object \| array) - Direct references to one or more objects to update. Accepts a single object or an array. (Objects returned from [selector](#selectorpath), etc.).
- `changes`(required, object) - New properties to apply (e.g., color, text visibility).
- `saveToHistory`(optional, boolean \| string) - Determines whether to record changes made by this `update` method in the `undoRedoManager`. If a string that matches the historyId of a previously saved record is provided, the two records will be merged into a single undo/redo step.
- `relativeTransform`(optional, boolean) - Determines whether to use relative values for `position`, `rotation`, and `angle`. If `true`, the provided values will be added to the object's values.
- `path` (optional, string) - Selector for the object to which the event will be applied, following [jsonpath](https://github.com/JSONPath-Plus/JSONPath) syntax.
- `elements` (optional, object \| array) - Direct references to one or more objects to update. Accepts a single object or an array. (Objects returned from [selector](#selectorpath), etc.).
- `changes` (optional, object) - New properties to apply (e.g., color, text visibility). If the `refresh` option is set to `true`, this can be omitted.
- `history` (optional, boolean \| string) - Determines whether to record changes made by this `update` method in the `undoRedoManager`. If a string that matches the historyId of a previously saved record is provided, the two records will be merged into a single undo/redo step.
- `relativeTransform` (optional, boolean) - Determines whether to use relative values for `position`, `rotation`, and `angle`. If `true`, the provided values will be added to the object's values.
- `arrayMerge` (optional, string) - Determines how to merge array properties. The default is `'merge'`.
- `'merge'` (default): Merges the target and source arrays.
- `'replace'`: Completely replaces the target array with the source array. Useful for forcing a specific state.
- `refresh` (optional, boolean) - If set to `true`, all property handlers are forcibly re-executed and the object is "refreshed" even if the values in `changes` are the same as before. This is useful when child objects need to be recalculated due to changes in the parent. Default is `false`.


```js
// Apply changes to objects with the label "grid-label-1"
patchmap.update({
path: `$..children[?(@.label=="grid-label-1")]`,
changes: {
components: [
{ type: 'icon', asset: 'wifi' }
]
}
item: {
components: [{ type: 'icon', source: 'wifi' }],
},
},
});

// Apply changes to objects of type "group"
Expand All @@ -252,10 +263,16 @@ patchmap.update({
patchmap.update({
path: `$..children[?(@.type=="group")].children[?(@.type=="grid")]`,
changes: {
components: [
{ type: 'icon', tint: 'black' }
]
}
item: {
components: [{ type: 'icon', tint: 'red' }],
},
},
});

// Force a full property update (refresh) for all objects of type "relations" using refresh: true
patchmap.update({
path: `$..children[?(@.type==="relations")]`,
refresh: true
});
```

Expand Down
116 changes: 66 additions & 50 deletions README_KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ npm install @conalog/patch-map

#### CDN
```html
<script src="https://cdn.jsdelivr.net/npm/pixi.js@8.9.2/dist/pixi.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@conalog/patch-map@v0.1.9/dist/index.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pixi.js@latest/dist/pixi.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@conalog/patch-map@latest/dist/index.umd.js"></script>
```

### 기본 예제
Expand All @@ -67,27 +67,30 @@ const data = [
type: 'group',
id: 'group-id-1',
label: 'group-label-1',
items: [{
children: [{
type: 'grid',
id: 'grid-1',
label: 'grid-label-1',
cells: [ [1, 0, 1], [1, 1, 1] ],
position: { x: 0, y: 0 },
itemSize: { width: 40, height: 80 },
components: [
{
type: 'background',
texture: {
type: 'rect',
fill: 'white',
borderWidth: 2,
borderColor: 'primary.dark',
radius: 4,
}
},
{ type: 'icon', asset: 'loading', size: 16 }
]
}]
gap: 4,
item: {
size: { width: 40, height: 80 },
components: [
{
type: 'background',
source: {
type: 'rect',
fill: 'white',
borderWidth: 2,
borderColor: 'primary.dark',
radius: 4,
}
},
{ type: 'icon', source: 'loading', tint: 'black', size: 16 },
]
},
}],
attrs: { x: 100, y: 100, },
}
];

Expand Down Expand Up @@ -185,27 +188,30 @@ const data = [
type: 'group',
id: 'group-id-1',
label: 'group-label-1',
items: [{
children: [{
type: 'grid',
id: 'grid-1',
label: 'grid-label-1',
cells: [ [1, 0, 1], [1, 1, 1] ],
position: { x: 0, y: 0 },
itemSize: { width: 40, height: 80 },
components: [
{
type: 'background',
texture: {
type: 'rect',
fill: 'white',
borderWidth: 2,
borderColor: 'primary.dark',
radius: 4,
}
},
{ type: 'icon', texture: 'loading', size: 16 }
]
}]
gap: 4,
item: {
size: { width: 40, height: 80 },
components: [
{
type: 'background',
source: {
type: 'rect',
fill: 'white',
borderWidth: 2,
borderColor: 'primary.dark',
radius: 4,
}
},
{ type: 'icon', source: 'loading', tint: 'black', size: 16 },
]
},
}],
attrs: { x: 100, y: 100, },
}
];
patchmap.draw(data);
Expand All @@ -219,24 +225,28 @@ draw method가 요구하는 **데이터 구조**입니다.
<br/>

### `update(options)`
캔버스에 이미 렌더링된 객체의 상태를 업데이트합니다. 색상이나 텍스트 가시성 같은 속성을 변경하는 데 사용하세요.
캔버스에 렌더링된 객체의 속성을 업데이트합니다. 기본적으로 변경된 속성만 반영하지만, refresh 또는 arrayMerge 옵션을 통해 업데이트 동작을 정밀하게 제어할 수 있습니다.

#### **`Options`**
- `path`(optional, string) - [jsonpath](https://github.com/JSONPath-Plus/JSONPath) 문법에 따른 selector로, 이벤트가 적용될 객체를 선택합니다.
- `elements`(optional, object \| array) - 업데이트할 하나 이상의 객체에 대한 직접 참조입니다. 단일 객체 또는 배열을 허용합니다. ([selector](#selectorpath)에서 반환된 객체 등).
- `changes`(required, object) - 적용할 새로운 속성 (예: 색상, 텍스트 가시성).
- `saveToHistory`(optional, boolean \| string) - 해당 `update` 메소드에 의한 변경 사항을 `undoRedoManager`에 기록할 것인지 결정합니다. 이전에 저장된 기록의 historyId와 일치하는 문자열이 제공되면, 두 기록이 하나의 실행 취소/재실행 단계로 병합됩니다.
- `relativeTransform`(optional, boolean) - `position`, `rotation`, `angle` 값에 대해서 상대값을 이용할 지 결정합니다. 만약, `true` 라면 전달된 값을 객체의 값에 더합니다.
- `path` (optional, string) - [jsonpath](https://github.com/JSONPath-Plus/JSONPath) 문법에 따른 selector로, 이벤트가 적용될 객체를 선택합니다.
- `elements` (optional, object \| array) - 업데이트할 하나 이상의 객체에 대한 직접 참조입니다. 단일 객체 또는 배열을 허용합니다. ([selector](#selectorpath)에서 반환된 객체 등).
- `changes` (optional, object) - 적용할 새로운 속성 (예: 색상, 텍스트 가시성). `refresh` 옵션을 `true`로 설정할 경우 생략할 수 있습니다.
- `history` (optional, boolean \| string) - 해당 `update` 메소드에 의한 변경 사항을 `undoRedoManager`에 기록할 것인지 결정합니다. 이전에 저장된 기록의 historyId와 일치하는 문자열이 제공되면, 두 기록이 하나의 실행 취소/재실행 단계로 병합됩니다.
- `relativeTransform` (optional, boolean) - `position`, `rotation`, `angle` 값에 대해서 상대값을 이용할 지 결정합니다. 만약, `true` 라면 전달된 값을 객체의 값에 더합니다.
- `arrayMerge` (optional, string) - 배열 속성을 병합하는 방식을 결정합니다. 기본값은 `'merge'` 입니다.
- `'merge'` (기본값): 대상 배열과 소스 배열을 병합합니다.
- `'replace'`: 대상 배열을 소스 배열로 완전히 교체하여, 특정 상태로 강제할 때 유용합니다.
- `refresh` (optional, boolean) - `true`로 설정하면, `changes`의 속성 값이 이전과 동일하더라도 모든 속성 핸들러를 강제로 다시 실행하여 객체를 "새로고침"합니다. 부모의 상태 변화에 따라 자식 객체를 다시 계산해야 할 때 유용합니다. 기본값은 `false` 입니다.

```js
// label이 "grid-label-1"인 객체들에 대해 변경 사항 적용
patchmap.update({
path: `$..children[?(@.label=="grid-label-1")]`,
changes: {
components: [
{ type: 'icon', asset: 'wifi' }
]
}
item: {
components: [{ type: 'icon', source: 'wifi' }],
},
},
});

// type이 "group"인 객체들에 대해 변경 사항 적용
Expand All @@ -251,10 +261,16 @@ patchmap.update({
patchmap.update({
path: `$..children[?(@.type=="group")].children[?(@.type=="grid")]`,
changes: {
components: [
{ type: 'icon', tint: 'black' }
]
}
item: {
components: [{ type: 'icon', tint: 'red' }],
},
},
});

// type이 "relations"인 모든 객체를 찾아서(refresh: true로) 강제로 전체 속성 업데이트(새로고침) 수행
patchmap.update({
path: `$..children[?(@.type==="relations")]`,
refresh: true
});
```

Expand Down
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"noConstructorReturn": "off"
},
"complexity": {
"noForEach": "off"
"noForEach": "off",
"noThisInStatic": "off"
}
}
},
Expand Down
Loading