@vaadin/hilla-react-signals 25.1.0 → 25.1.1
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/ListSignal.js.map +1 -1
- package/package.json +2 -2
package/ListSignal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListSignal.js","sourceRoot":"","sources":["src/ListSignal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,IAAI,GAOL,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,GAGR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM/C,MAAM,OAAO,UAAc,SAAQ,gBAAuC;IACxE,YAAY,MAA8B,EAAE,EAAW;QACrD,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACxB,CAAC;IAOD,WAAW,CAAC,KAAQ;QAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;IAOD,UAAU,CAAC,KAAQ;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;IAQD,QAAQ,CAAC,KAAQ,EAAE,EAAgB;QACjC,MAAM,OAAO,GAAG,mBAAmB,CAAI,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;Q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iBAAiB,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACxD,CAAC;aAAM,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;YACtC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;YAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;YAE3B,MAAM,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC;YAC1C,MAAM,YAAY,GAAG,WAAW;iBAC7B,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;gBACf,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;gBACjC,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;oBACzB,OAAO,IAAI,WAAW,CAAI,SAAS,CAAC,KAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;gBACrF,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAA0B,CAAC;YAE5C,IAAI,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,CAAC;YACrC,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { CollectionSignal } from './CollectionSignal.js';\nimport {\n createInsertCommand,\n createRemoveCommand,\n isAdoptAtCommand,\n isInsertCommand,\n isPositionCondition,\n isRemoveCommand,\n isSetCommand,\n isSnapshotCommand,\n ListPosition,\n ZERO,\n type AdoptAtCommand,\n type InsertCommand,\n type PositionCondition,\n type RemoveCommand,\n type SetCommand,\n type SnapshotCommand,\n} from './commands.js';\nimport {\n $createOperation,\n $processServerResponse,\n $resolveOperation,\n $setValueQuietly,\n $update,\n type Operation,\n type ServerConnectionConfig,\n} from './FullStackSignal.js';\nimport { ValueSignal } from './ValueSignal.js';\n\n/**\n * A signal containing a list of values. Supports atomic updates to the list structure.\n * Each value in the list is accessed as a separate ValueSignal instance.\n */\nexport class ListSignal<T> extends CollectionSignal<Array<ValueSignal<T>>> {\n constructor(config: ServerConnectionConfig, id?: string) {\n super([], config, id);\n }\n\n /**\n * Inserts a value as the first entry in this list.\n * @param value - The value to insert\n * @returns An operation containing a signal for the inserted entry and the eventual result\n */\n insertFirst(value: T): Operation {\n return this.insertAt(value, ListPosition.first());\n }\n\n /**\n * Inserts a value as the last entry in this list.\n * @param value - The value to insert\n * @returns An operation containing a signal for the inserted entry and the eventual result\n */\n insertLast(value: T): Operation {\n return this.insertAt(value, ListPosition.last());\n }\n\n /**\n * Inserts a value at the given position in this list.\n * @param value - The value to insert\n * @param at - The insert position\n * @returns An operation containing a signal for the inserted entry and the eventual result\n */\n insertAt(value: T, at: ListPosition): Operation {\n const command = createInsertCommand<T>(ZERO, value, at);\n const promise = this[$update](command);\n return this[$createOperation]({ id: command.commandId, promise });\n }\n\n /**\n * Removes the given child from this list.\n * @param child - The child to remove\n * @returns An operation containing the eventual result\n */\n remove(child: ValueSignal<T>): Operation {\n const command = createRemoveCommand(child.id, ZERO);\n const promise = this[$update](command);\n return this[$createOperation]({ id: command.commandId, promise });\n }\n\n protected override [$processServerResponse](\n command: InsertCommand<T> | RemoveCommand | AdoptAtCommand | PositionCondition | SnapshotCommand | SetCommand<T>,\n ): void {\n // Check if the command has a targetNodeId and reroute it to the corresponding child\n if ((isSnapshotCommand(command) || isSetCommand(command)) && command.targetNodeId) {\n const targetChild = this.value.find((child) => child.id === command.targetNodeId);\n\n if (targetChild) {\n targetChild[$processServerResponse](command);\n return;\n }\n }\n\n if (isInsertCommand<T>(command)) {\n const valueSignal = new ValueSignal<T>(command.value, this.server.config, command.commandId, this);\n let insertIndex = this.value.length;\n const pos = command.position;\n if (pos.after === '' && pos.before == null) {\n insertIndex = 0;\n } else if (pos.after == null && pos.before === '') {\n insertIndex = this.value.length;\n } else if (typeof pos.after === 'string' && pos.after !== '') {\n const idx = this.value.findIndex((v) => v.id === pos.after);\n insertIndex = idx !== -1 ? idx + 1 : this.value.length;\n } else if (typeof pos.before === 'string' && pos.before !== '') {\n const idx = this.value.findIndex((v) => v.id === pos.before);\n insertIndex = idx !== -1 ? idx : this.value.length;\n }\n const newList = [...this.value.slice(0, insertIndex), valueSignal, ...this.value.slice(insertIndex)];\n this[$setValueQuietly](newList);\n this[$resolveOperation](command.commandId, undefined);\n } else if (isRemoveCommand(command)) {\n const removeIndex = this.value.findIndex((child) => child.id === command.targetNodeId);\n if (removeIndex !== -1) {\n const newList = [...this.value.slice(0, removeIndex), ...this.value.slice(removeIndex + 1)];\n this[$setValueQuietly](newList);\n }\n this[$resolveOperation](command.commandId, undefined);\n } else if (isAdoptAtCommand(command)) {\n const moveIndex = this.value.findIndex((child) => child.id === command.childId);\n if (moveIndex !== -1) {\n const [movedChild] = this.value.splice(moveIndex, 1);\n let newIndex = this.value.length;\n const pos = command.position;\n if (pos.after === '' && pos.before == null) {\n newIndex = 0;\n } else if (pos.after == null && pos.before === '') {\n newIndex = this.value.length;\n } else if (typeof pos.after === 'string' && pos.after !== '') {\n const idx = this.value.findIndex((v) => v.id === pos.after);\n newIndex = idx !== -1 ? idx + 1 : this.value.length;\n } else if (typeof pos.before === 'string' && pos.before !== '') {\n const idx = this.value.findIndex((v) => v.id === pos.before);\n newIndex = idx !== -1 ? idx : this.value.length;\n }\n this.value.splice(newIndex, 0, movedChild);\n }\n this[$resolveOperation](command.commandId, undefined);\n } else if (isPositionCondition(command)) {\n this[$resolveOperation](command.commandId, undefined);\n } else if (isSnapshotCommand(command)) {\n const { nodes } = command;\n const listNode = nodes[''];\n\n const childrenIds = listNode.listChildren;\n const valueSignals = childrenIds\n .map((childId) => {\n const childNode = nodes[childId];\n if ('value' in childNode) {\n return new ValueSignal<T>(childNode.value as T, this.server.config, childId, this);\n }\n return null;\n })\n .filter(Boolean) as Array<ValueSignal<T>>;\n\n this[$setValueQuietly](valueSignals);\n this[$resolveO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OAAO,CAAC;YAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;YAE3B,MAAM,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC;YAC1C,MAAM,YAAY,GAAG,WAAW;iBAC7B,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;gBACf,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;gBACjC,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;oBACzB,OAAO,IAAI,WAAW,CAAI,SAAS,CAAC,KAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;gBACrF,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAA0B,CAAC;YAE5C,IAAI,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,CAAC;YACrC,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { CollectionSignal } from './CollectionSignal.js';\nimport {\n createInsertCommand,\n createRemoveCommand,\n isAdoptAtCommand,\n isInsertCommand,\n isPositionCondition,\n isRemoveCommand,\n isSetCommand,\n isSnapshotCommand,\n ListPosition,\n ZERO,\n type AdoptAtCommand,\n type InsertCommand,\n type PositionCondition,\n type RemoveCommand,\n type SetCommand,\n type SnapshotCommand,\n} from './commands.js';\nimport {\n $createOperation,\n $processServerResponse,\n $resolveOperation,\n $setValueQuietly,\n $update,\n type Operation,\n type ServerConnectionConfig,\n} from './FullStackSignal.js';\nimport { ValueSignal } from './ValueSignal.js';\n\n/**\n * A signal containing a list of values. Supports atomic updates to the list structure.\n * Each value in the list is accessed as a separate ValueSignal instance.\n */\nexport class ListSignal<T> extends CollectionSignal<Array<ValueSignal<T>>> {\n constructor(config: ServerConnectionConfig, id?: string) {\n super([], config, id);\n }\n\n /**\n * Inserts a value as the first entry in this list.\n * @param value - The value to insert\n * @returns An operation containing a signal for the inserted entry and the eventual result\n */\n insertFirst(value: T): Operation {\n return this.insertAt(value, ListPosition.first());\n }\n\n /**\n * Inserts a value as the last entry in this list.\n * @param value - The value to insert\n * @returns An operation containing a signal for the inserted entry and the eventual result\n */\n insertLast(value: T): Operation {\n return this.insertAt(value, ListPosition.last());\n }\n\n /**\n * Inserts a value at the given position in this list.\n * @param value - The value to insert\n * @param at - The insert position\n * @returns An operation containing a signal for the inserted entry and the eventual result\n */\n insertAt(value: T, at: ListPosition): Operation {\n const command = createInsertCommand(ZERO, value, at);\n const promise = this[$update](command);\n return this[$createOperation]({ id: command.commandId, promise });\n }\n\n /**\n * Removes the given child from this list.\n * @param child - The child to remove\n * @returns An operation containing the eventual result\n */\n remove(child: ValueSignal<T>): Operation {\n const command = createRemoveCommand(child.id, ZERO);\n const promise = this[$update](command);\n return this[$createOperation]({ id: command.commandId, promise });\n }\n\n protected override [$processServerResponse](\n command: InsertCommand<T> | RemoveCommand | AdoptAtCommand | PositionCondition | SnapshotCommand | SetCommand<T>,\n ): void {\n // Check if the command has a targetNodeId and reroute it to the corresponding child\n if ((isSnapshotCommand(command) || isSetCommand(command)) && command.targetNodeId) {\n const targetChild = this.value.find((child) => child.id === command.targetNodeId);\n\n if (targetChild) {\n targetChild[$processServerResponse](command);\n return;\n }\n }\n\n if (isInsertCommand<T>(command)) {\n const valueSignal = new ValueSignal<T>(command.value, this.server.config, command.commandId, this);\n let insertIndex = this.value.length;\n const pos = command.position;\n if (pos.after === '' && pos.before == null) {\n insertIndex = 0;\n } else if (pos.after == null && pos.before === '') {\n insertIndex = this.value.length;\n } else if (typeof pos.after === 'string' && pos.after !== '') {\n const idx = this.value.findIndex((v) => v.id === pos.after);\n insertIndex = idx !== -1 ? idx + 1 : this.value.length;\n } else if (typeof pos.before === 'string' && pos.before !== '') {\n const idx = this.value.findIndex((v) => v.id === pos.before);\n insertIndex = idx !== -1 ? idx : this.value.length;\n }\n const newList = [...this.value.slice(0, insertIndex), valueSignal, ...this.value.slice(insertIndex)];\n this[$setValueQuietly](newList);\n this[$resolveOperation](command.commandId, undefined);\n } else if (isRemoveCommand(command)) {\n const removeIndex = this.value.findIndex((child) => child.id === command.targetNodeId);\n if (removeIndex !== -1) {\n const newList = [...this.value.slice(0, removeIndex), ...this.value.slice(removeIndex + 1)];\n this[$setValueQuietly](newList);\n }\n this[$resolveOperation](command.commandId, undefined);\n } else if (isAdoptAtCommand(command)) {\n const moveIndex = this.value.findIndex((child) => child.id === command.childId);\n if (moveIndex !== -1) {\n const [movedChild] = this.value.splice(moveIndex, 1);\n let newIndex = this.value.length;\n const pos = command.position;\n if (pos.after === '' && pos.before == null) {\n newIndex = 0;\n } else if (pos.after == null && pos.before === '') {\n newIndex = this.value.length;\n } else if (typeof pos.after === 'string' && pos.after !== '') {\n const idx = this.value.findIndex((v) => v.id === pos.after);\n newIndex = idx !== -1 ? idx + 1 : this.value.length;\n } else if (typeof pos.before === 'string' && pos.before !== '') {\n const idx = this.value.findIndex((v) => v.id === pos.before);\n newIndex = idx !== -1 ? idx : this.value.length;\n }\n this.value.splice(newIndex, 0, movedChild);\n }\n this[$resolveOperation](command.commandId, undefined);\n } else if (isPositionCondition(command)) {\n this[$resolveOperation](command.commandId, undefined);\n } else if (isSnapshotCommand(command)) {\n const { nodes } = command;\n const listNode = nodes[''];\n\n const childrenIds = listNode.listChildren;\n const valueSignals = childrenIds\n .map((childId) => {\n const childNode = nodes[childId];\n if ('value' in childNode) {\n return new ValueSignal<T>(childNode.value as T, this.server.config, childId, this);\n }\n return null;\n })\n .filter(Boolean) as Array<ValueSignal<T>>;\n\n this[$setValueQuietly](valueSignals);\n this[$resolveOperation](command.commandId, undefined);\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/hilla-react-signals",
|
|
3
|
-
"version": "25.1.
|
|
3
|
+
"version": "25.1.1",
|
|
4
4
|
"description": "Signals for Hilla React",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@preact/signals-react": "3.0.1",
|
|
48
|
-
"@vaadin/hilla-frontend": "25.1.
|
|
48
|
+
"@vaadin/hilla-frontend": "25.1.1",
|
|
49
49
|
"nanoid": "5.0.9"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|