tinybase 5.0.1 → 5.0.3
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/@types/synchronizers/synchronizer-ws-server/index.d.cts +32 -27
- package/@types/synchronizers/synchronizer-ws-server/index.d.ts +32 -27
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.cts +32 -27
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +32 -27
- package/@types/ui-react/index.d.cts +62 -45
- package/@types/ui-react/index.d.ts +62 -45
- package/@types/ui-react/with-schemas/index.d.cts +83 -59
- package/@types/ui-react/with-schemas/index.d.ts +83 -59
- package/cjs/es6/min/synchronizers/synchronizer-ws-server/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-ws-server/index.cjs.gz +0 -0
- package/cjs/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/ui-react/index.cjs +1 -1
- package/cjs/es6/min/ui-react/index.cjs.gz +0 -0
- package/cjs/es6/min/ui-react/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/ui-react/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/synchronizers/synchronizer-ws-server/index.cjs +4 -6
- package/cjs/es6/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +4 -6
- package/cjs/es6/ui-react/index.cjs +13 -6
- package/cjs/es6/ui-react/with-schemas/index.cjs +13 -6
- package/cjs/min/synchronizers/synchronizer-ws-server/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-ws-server/index.cjs.gz +0 -0
- package/cjs/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +1 -1
- package/cjs/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/ui-react/index.cjs +1 -1
- package/cjs/min/ui-react/index.cjs.gz +0 -0
- package/cjs/min/ui-react/with-schemas/index.cjs +1 -1
- package/cjs/min/ui-react/with-schemas/index.cjs.gz +0 -0
- package/cjs/synchronizers/synchronizer-ws-server/index.cjs +4 -4
- package/cjs/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +4 -4
- package/cjs/ui-react/index.cjs +11 -6
- package/cjs/ui-react/with-schemas/index.cjs +11 -6
- package/es6/min/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/es6/min/ui-react/index.js +1 -1
- package/es6/min/ui-react/index.js.gz +0 -0
- package/es6/min/ui-react/with-schemas/index.js +1 -1
- package/es6/min/ui-react/with-schemas/index.js.gz +0 -0
- package/es6/synchronizers/synchronizer-ws-server/index.js +4 -6
- package/es6/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -6
- package/es6/ui-react/index.js +13 -6
- package/es6/ui-react/with-schemas/index.js +13 -6
- package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/min/ui-react/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/with-schemas/index.js.gz +0 -0
- package/package.json +1 -1
- package/readme.md +2 -2
- package/synchronizers/synchronizer-ws-server/index.js +4 -4
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -4
- package/ui-react/index.js +11 -6
- package/ui-react/with-schemas/index.js +11 -6
- package/umd/es6/min/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/umd/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/umd/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/ui-react/index.js +1 -1
- package/umd/es6/min/ui-react/index.js.gz +0 -0
- package/umd/es6/min/ui-react/with-schemas/index.js +1 -1
- package/umd/es6/min/ui-react/with-schemas/index.js.gz +0 -0
- package/umd/es6/synchronizers/synchronizer-ws-server/index.js +4 -6
- package/umd/es6/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -6
- package/umd/es6/ui-react/index.js +16 -6
- package/umd/es6/ui-react/with-schemas/index.js +16 -6
- package/umd/min/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/umd/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/umd/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/umd/min/ui-react/index.js +1 -1
- package/umd/min/ui-react/index.js.gz +0 -0
- package/umd/min/ui-react/with-schemas/index.js +1 -1
- package/umd/min/ui-react/with-schemas/index.js.gz +0 -0
- package/umd/synchronizers/synchronizer-ws-server/index.js +4 -6
- package/umd/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -6
- package/umd/ui-react/index.js +12 -6
- package/umd/ui-react/with-schemas/index.js +12 -6
|
@@ -3000,7 +3000,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
3000
3000
|
* @param getTableDeps An optional array of dependencies for the `getTable`
|
|
3001
3001
|
* function, which, if any change, result in the regeneration of the callback.
|
|
3002
3002
|
* This parameter defaults to an empty array. Also use this to indicate the
|
|
3003
|
-
* dependencies of a GetId
|
|
3003
|
+
* dependencies of a GetId function if used as the tableId argument.
|
|
3004
3004
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
3005
3005
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
3006
3006
|
* reference.
|
|
@@ -3237,7 +3237,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
3237
3237
|
* @param getRowDeps An optional array of dependencies for the `getRow`
|
|
3238
3238
|
* function, which, if any change, result in the regeneration of the callback.
|
|
3239
3239
|
* This parameter defaults to an empty array. Also use this to indicate the
|
|
3240
|
-
* dependencies of a GetId
|
|
3240
|
+
* dependencies of a GetId function if used as the tableId argument.
|
|
3241
3241
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
3242
3242
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
3243
3243
|
* reference.
|
|
@@ -3934,7 +3934,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
3934
3934
|
* ```
|
|
3935
3935
|
*
|
|
3936
3936
|
* This hook is useful, for example, when creating an event handler that will
|
|
3937
|
-
* delete data in
|
|
3937
|
+
* delete data in the Store.
|
|
3938
3938
|
*
|
|
3939
3939
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
3940
3940
|
* set of dependencies) which will be called just after the Store has been
|
|
@@ -3998,22 +3998,23 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
3998
3998
|
) => Callback;
|
|
3999
3999
|
|
|
4000
4000
|
/**
|
|
4001
|
-
* The useDelTableCallback hook returns a callback that can be
|
|
4002
|
-
* single Table from a Store.
|
|
4001
|
+
* The useDelTableCallback hook returns a parameterized callback that can be
|
|
4002
|
+
* used to remove a single Table from a Store.
|
|
4003
4003
|
*
|
|
4004
4004
|
* This has schema-based typing. The following is a simplified representation:
|
|
4005
4005
|
*
|
|
4006
4006
|
* ```ts override
|
|
4007
|
-
* useDelTableCallback(
|
|
4008
|
-
* tableId: Id
|
|
4007
|
+
* useDelTableCallback<Parameter>(
|
|
4008
|
+
* tableId: Id | GetId<Parameter>,
|
|
4009
4009
|
* storeOrStoreId?: StoreOrStoreId,
|
|
4010
4010
|
* then?: (store: Store) => void,
|
|
4011
4011
|
* thenDeps?: React.DependencyList,
|
|
4012
|
-
* ):
|
|
4012
|
+
* ): ParameterizedCallback<Parameter>;
|
|
4013
4013
|
* ```
|
|
4014
4014
|
*
|
|
4015
4015
|
* This hook is useful, for example, when creating an event handler that will
|
|
4016
|
-
* delete data in
|
|
4016
|
+
* delete data in the Store. In this case, the parameter will likely be the
|
|
4017
|
+
* event, so that you can use data from it as part of the deletion.
|
|
4017
4018
|
*
|
|
4018
4019
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
4019
4020
|
* set of dependencies) which will be called just after the Store has been
|
|
@@ -4023,7 +4024,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4023
4024
|
* The Store to which the callback will make the deletion (indicated by the
|
|
4024
4025
|
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
4025
4026
|
* dependency for the callback.
|
|
4026
|
-
* @param tableId The Id of the Table in the Store
|
|
4027
|
+
* @param tableId The Id of the Table in the Store to delete, or a GetId
|
|
4028
|
+
* function that will return it.
|
|
4027
4029
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
4028
4030
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
4029
4031
|
* reference.
|
|
@@ -4031,8 +4033,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4031
4033
|
* to the Store.
|
|
4032
4034
|
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
4033
4035
|
* which, if any change, result in the regeneration of the callback. This
|
|
4034
|
-
* parameter defaults to an empty array.
|
|
4035
|
-
*
|
|
4036
|
+
* parameter defaults to an empty array. Also use this to indicate the
|
|
4037
|
+
* dependencies of an GetId function if used as the tableId argument.
|
|
4038
|
+
* @returns A parameterized callback for subsequent use.
|
|
4036
4039
|
* @example
|
|
4037
4040
|
* This example uses the useDelTableCallback hook to create an event handler
|
|
4038
4041
|
* which deletes from the Store when the `span` element is clicked.
|
|
@@ -4071,31 +4074,35 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4071
4074
|
* @category Store hooks
|
|
4072
4075
|
* @since v1.0.0
|
|
4073
4076
|
*/
|
|
4074
|
-
useDelTableCallback: <
|
|
4075
|
-
|
|
4077
|
+
useDelTableCallback: <
|
|
4078
|
+
Parameter,
|
|
4079
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
4080
|
+
>(
|
|
4081
|
+
tableId: TableId | GetId<Schemas, Parameter, TableId>,
|
|
4076
4082
|
storeOrStoreId?: StoreOrStoreId<Schemas>,
|
|
4077
4083
|
then?: (store: Store<Schemas>) => void,
|
|
4078
4084
|
thenDeps?: React.DependencyList,
|
|
4079
|
-
) =>
|
|
4085
|
+
) => ParameterizedCallback<Parameter>;
|
|
4080
4086
|
|
|
4081
4087
|
/**
|
|
4082
|
-
* The useDelRowCallback hook returns a callback that can be used
|
|
4083
|
-
* single Row from a Table.
|
|
4088
|
+
* The useDelRowCallback hook returns a parameterized callback that can be used
|
|
4089
|
+
* to remove a single Row from a Table.
|
|
4084
4090
|
*
|
|
4085
4091
|
* This has schema-based typing. The following is a simplified representation:
|
|
4086
4092
|
*
|
|
4087
4093
|
* ```ts override
|
|
4088
|
-
* useDelRowCallback(
|
|
4089
|
-
* tableId: Id
|
|
4090
|
-
* rowId: Id
|
|
4094
|
+
* useDelRowCallback<Parameter>(
|
|
4095
|
+
* tableId: Id | GetId<Parameter>,
|
|
4096
|
+
* rowId: Id | GetId<Parameter>,
|
|
4091
4097
|
* storeOrStoreId?: StoreOrStoreId,
|
|
4092
4098
|
* then?: (store: Store) => void,
|
|
4093
4099
|
* thenDeps?: React.DependencyList,
|
|
4094
|
-
* ):
|
|
4100
|
+
* ): ParameterizedCallback<Parameter>;
|
|
4095
4101
|
* ```
|
|
4096
4102
|
*
|
|
4097
4103
|
* This hook is useful, for example, when creating an event handler that will
|
|
4098
|
-
* delete data in
|
|
4104
|
+
* delete data in the Store. In this case, the parameter will likely be the
|
|
4105
|
+
* event, so that you can use data from it as part of the deletion.
|
|
4099
4106
|
*
|
|
4100
4107
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
4101
4108
|
* set of dependencies) which will be called just after the Store has been
|
|
@@ -4105,8 +4112,10 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4105
4112
|
* The Store to which the callback will make the deletion (indicated by the
|
|
4106
4113
|
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
4107
4114
|
* dependency for the callback.
|
|
4108
|
-
* @param tableId The Id of the Table in the Store
|
|
4109
|
-
*
|
|
4115
|
+
* @param tableId The Id of the Table in the Store, or a GetId function that
|
|
4116
|
+
* will return it.
|
|
4117
|
+
* @param rowId The Id of the Row in the Table to delete, or a GetId function
|
|
4118
|
+
* that will return it.
|
|
4110
4119
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
4111
4120
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
4112
4121
|
* reference.
|
|
@@ -4114,8 +4123,10 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4114
4123
|
* to the Store.
|
|
4115
4124
|
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
4116
4125
|
* which, if any change, result in the regeneration of the callback. This
|
|
4117
|
-
* parameter defaults to an empty array.
|
|
4118
|
-
*
|
|
4126
|
+
* parameter defaults to an empty array. Also use this to indicate the
|
|
4127
|
+
* dependencies of any GetId functions if used as the tableId or rowId
|
|
4128
|
+
* arguments.
|
|
4129
|
+
* @returns A parameterized callback for subsequent use.
|
|
4119
4130
|
* @example
|
|
4120
4131
|
* This example uses the useDelRowCallback hook to create an event handler which
|
|
4121
4132
|
* deletes from the Store when the `span` element is clicked.
|
|
@@ -4154,34 +4165,35 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4154
4165
|
* @category Store hooks
|
|
4155
4166
|
* @since v1.0.0
|
|
4156
4167
|
*/
|
|
4157
|
-
useDelRowCallback: <TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
4158
|
-
tableId: TableId,
|
|
4159
|
-
rowId: Id,
|
|
4168
|
+
useDelRowCallback: <Parameter, TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
4169
|
+
tableId: TableId | GetId<Schemas, Parameter, TableId>,
|
|
4170
|
+
rowId: Id | GetId<Schemas, Parameter, Id>,
|
|
4160
4171
|
storeOrStoreId?: StoreOrStoreId<Schemas>,
|
|
4161
4172
|
then?: (store: Store<Schemas>) => void,
|
|
4162
4173
|
thenDeps?: React.DependencyList,
|
|
4163
|
-
) =>
|
|
4174
|
+
) => ParameterizedCallback<Parameter>;
|
|
4164
4175
|
|
|
4165
4176
|
/**
|
|
4166
|
-
* The useDelCellCallback hook returns a callback that can be used
|
|
4167
|
-
* single Cell from a Row.
|
|
4177
|
+
* The useDelCellCallback hook returns a parameterized callback that can be used
|
|
4178
|
+
* to remove a single Cell from a Row.
|
|
4168
4179
|
*
|
|
4169
4180
|
* This has schema-based typing. The following is a simplified representation:
|
|
4170
4181
|
*
|
|
4171
4182
|
* ```ts override
|
|
4172
|
-
* useDelCellCallback(
|
|
4173
|
-
* tableId: Id
|
|
4174
|
-
* rowId: Id
|
|
4175
|
-
* cellId: Id
|
|
4183
|
+
* useDelCellCallback<Parameter>(
|
|
4184
|
+
* tableId: Id | GetId<Parameter>,
|
|
4185
|
+
* rowId: Id | GetId<Parameter>,
|
|
4186
|
+
* cellId: Id | GetId<Parameter>,
|
|
4176
4187
|
* forceDel?: boolean,
|
|
4177
4188
|
* storeOrStoreId?: StoreOrStoreId,
|
|
4178
4189
|
* then?: (store: Store) => void,
|
|
4179
4190
|
* thenDeps?: React.DependencyList,
|
|
4180
|
-
* ):
|
|
4191
|
+
* ): ParameterizedCallback<Parameter>;
|
|
4181
4192
|
* ```
|
|
4182
4193
|
*
|
|
4183
4194
|
* This hook is useful, for example, when creating an event handler that will
|
|
4184
|
-
* delete data in
|
|
4195
|
+
* delete data in the Store. In this case, the parameter will likely be the
|
|
4196
|
+
* event, so that you can use data from it as part of the deletion.
|
|
4185
4197
|
*
|
|
4186
4198
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
4187
4199
|
* set of dependencies) which will be called just after the Store has been
|
|
@@ -4191,9 +4203,12 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4191
4203
|
* The Store to which the callback will make the deletion (indicated by the
|
|
4192
4204
|
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
4193
4205
|
* dependency for the callback.
|
|
4194
|
-
* @param tableId The Id of the Table in the Store
|
|
4195
|
-
*
|
|
4196
|
-
* @param
|
|
4206
|
+
* @param tableId The Id of the Table in the Store, or a GetId function that
|
|
4207
|
+
* will return it.
|
|
4208
|
+
* @param rowId The Id of the Row in the Table, or a GetId function that will
|
|
4209
|
+
* return it.
|
|
4210
|
+
* @param cellId The Id of the Cell in the Row to delete, or a GetId function
|
|
4211
|
+
* that will return it.
|
|
4197
4212
|
* @param forceDel An optional flag to indicate that the whole Row should be
|
|
4198
4213
|
* deleted, even if a TablesSchema provides a default value for this Cell.
|
|
4199
4214
|
* Defaults to `false`.
|
|
@@ -4204,8 +4219,10 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4204
4219
|
* to the Store.
|
|
4205
4220
|
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
4206
4221
|
* which, if any change, result in the regeneration of the callback. This
|
|
4207
|
-
* parameter defaults to an empty array.
|
|
4208
|
-
*
|
|
4222
|
+
* parameter defaults to an empty array. Also use this to indicate the
|
|
4223
|
+
* dependencies of any GetId functions if used as the tableId, rowId, or cellId
|
|
4224
|
+
* arguments.
|
|
4225
|
+
* @returns A parameterized callback for subsequent use.
|
|
4209
4226
|
* @example
|
|
4210
4227
|
* This example uses the useDelCellCallback hook to create an event handler
|
|
4211
4228
|
* which deletes from the Store when the `span` element is clicked.
|
|
@@ -4250,17 +4267,18 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4250
4267
|
* @since v1.0.0
|
|
4251
4268
|
*/
|
|
4252
4269
|
useDelCellCallback: <
|
|
4270
|
+
Parameter,
|
|
4253
4271
|
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
4254
4272
|
CellId extends CellIdFromSchema<Schemas[0], TableId>,
|
|
4255
4273
|
>(
|
|
4256
|
-
tableId: TableId,
|
|
4257
|
-
rowId: Id,
|
|
4258
|
-
cellId: CellId,
|
|
4274
|
+
tableId: TableId | GetId<Schemas, Parameter, TableId>,
|
|
4275
|
+
rowId: Id | GetId<Schemas, Parameter, Id>,
|
|
4276
|
+
cellId: CellId | GetId<Schemas, Parameter, CellId>,
|
|
4259
4277
|
forceDel?: boolean,
|
|
4260
4278
|
storeOrStoreId?: StoreOrStoreId<Schemas>,
|
|
4261
4279
|
then?: (store: Store<Schemas>) => void,
|
|
4262
4280
|
thenDeps?: React.DependencyList,
|
|
4263
|
-
) =>
|
|
4281
|
+
) => ParameterizedCallback<Parameter>;
|
|
4264
4282
|
|
|
4265
4283
|
/**
|
|
4266
4284
|
* The useDelValuesCallback hook returns a callback that can be used to remove
|
|
@@ -4341,22 +4359,23 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4341
4359
|
) => Callback;
|
|
4342
4360
|
|
|
4343
4361
|
/**
|
|
4344
|
-
* The useDelValueCallback hook returns a callback that can be
|
|
4345
|
-
* single Value from a Store.
|
|
4362
|
+
* The useDelValueCallback hook returns a parameterized callback that can be
|
|
4363
|
+
* used to remove a single Value from a Store.
|
|
4346
4364
|
*
|
|
4347
4365
|
* This has schema-based typing. The following is a simplified representation:
|
|
4348
4366
|
*
|
|
4349
4367
|
* ```ts override
|
|
4350
|
-
* useDelValueCallback(
|
|
4351
|
-
* valueId: Id
|
|
4368
|
+
* useDelValueCallback<Parameter>(
|
|
4369
|
+
* valueId: Id | GetId<Parameter>,
|
|
4352
4370
|
* storeOrStoreId?: StoreOrStoreId,
|
|
4353
4371
|
* then?: (store: Store) => void,
|
|
4354
4372
|
* thenDeps?: React.DependencyList,
|
|
4355
|
-
* ):
|
|
4373
|
+
* ): ParameterizedCallback<Parameter>;
|
|
4356
4374
|
* ```
|
|
4357
4375
|
*
|
|
4358
4376
|
* This hook is useful, for example, when creating an event handler that will
|
|
4359
|
-
* delete data in
|
|
4377
|
+
* delete data in the Store. In this case, the parameter will likely be the
|
|
4378
|
+
* event, so that you can use data from it as part of the deletion.
|
|
4360
4379
|
*
|
|
4361
4380
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
4362
4381
|
* set of dependencies) which will be called just after the Store has been
|
|
@@ -4366,7 +4385,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4366
4385
|
* The Store to which the callback will make the deletion (indicated by the
|
|
4367
4386
|
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
4368
4387
|
* dependency for the callback.
|
|
4369
|
-
* @param valueId The Id of the Value in the Store
|
|
4388
|
+
* @param valueId The Id of the Value in the Store to delete, or a GetId
|
|
4389
|
+
* function that will return it.
|
|
4370
4390
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
4371
4391
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
4372
4392
|
* reference.
|
|
@@ -4374,8 +4394,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4374
4394
|
* to the Store.
|
|
4375
4395
|
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
4376
4396
|
* which, if any change, result in the regeneration of the callback. This
|
|
4377
|
-
* parameter defaults to an empty array.
|
|
4378
|
-
*
|
|
4397
|
+
* parameter defaults to an empty array. Also use this to indicate the
|
|
4398
|
+
* dependencies of a GetId function if used as the valueId argument.
|
|
4399
|
+
* @returns A parameterized callback for subsequent use.
|
|
4379
4400
|
* @example
|
|
4380
4401
|
* This example uses the useDelValueCallback hook to create an event handler
|
|
4381
4402
|
* which deletes from the Store when the `span` element is clicked.
|
|
@@ -4414,12 +4435,15 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4414
4435
|
* @category Store hooks
|
|
4415
4436
|
* @since v3.0.0
|
|
4416
4437
|
*/
|
|
4417
|
-
useDelValueCallback: <
|
|
4418
|
-
|
|
4438
|
+
useDelValueCallback: <
|
|
4439
|
+
Parameter,
|
|
4440
|
+
ValueId extends ValueIdFromSchema<Schemas[1]>,
|
|
4441
|
+
>(
|
|
4442
|
+
valueId: ValueId | GetId<Schemas, Parameter, ValueId>,
|
|
4419
4443
|
storeOrStoreId?: StoreOrStoreId<Schemas>,
|
|
4420
4444
|
then?: (store: Store<Schemas>) => void,
|
|
4421
4445
|
thenDeps?: React.DependencyList,
|
|
4422
|
-
) =>
|
|
4446
|
+
) => ParameterizedCallback<Parameter>;
|
|
4423
4447
|
|
|
4424
4448
|
/**
|
|
4425
4449
|
* The useHasTablesListener hook registers a listener function with the Store
|
|
@@ -3000,7 +3000,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
3000
3000
|
* @param getTableDeps An optional array of dependencies for the `getTable`
|
|
3001
3001
|
* function, which, if any change, result in the regeneration of the callback.
|
|
3002
3002
|
* This parameter defaults to an empty array. Also use this to indicate the
|
|
3003
|
-
* dependencies of a GetId
|
|
3003
|
+
* dependencies of a GetId function if used as the tableId argument.
|
|
3004
3004
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
3005
3005
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
3006
3006
|
* reference.
|
|
@@ -3237,7 +3237,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
3237
3237
|
* @param getRowDeps An optional array of dependencies for the `getRow`
|
|
3238
3238
|
* function, which, if any change, result in the regeneration of the callback.
|
|
3239
3239
|
* This parameter defaults to an empty array. Also use this to indicate the
|
|
3240
|
-
* dependencies of a GetId
|
|
3240
|
+
* dependencies of a GetId function if used as the tableId argument.
|
|
3241
3241
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
3242
3242
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
3243
3243
|
* reference.
|
|
@@ -3934,7 +3934,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
3934
3934
|
* ```
|
|
3935
3935
|
*
|
|
3936
3936
|
* This hook is useful, for example, when creating an event handler that will
|
|
3937
|
-
* delete data in
|
|
3937
|
+
* delete data in the Store.
|
|
3938
3938
|
*
|
|
3939
3939
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
3940
3940
|
* set of dependencies) which will be called just after the Store has been
|
|
@@ -3998,22 +3998,23 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
3998
3998
|
) => Callback;
|
|
3999
3999
|
|
|
4000
4000
|
/**
|
|
4001
|
-
* The useDelTableCallback hook returns a callback that can be
|
|
4002
|
-
* single Table from a Store.
|
|
4001
|
+
* The useDelTableCallback hook returns a parameterized callback that can be
|
|
4002
|
+
* used to remove a single Table from a Store.
|
|
4003
4003
|
*
|
|
4004
4004
|
* This has schema-based typing. The following is a simplified representation:
|
|
4005
4005
|
*
|
|
4006
4006
|
* ```ts override
|
|
4007
|
-
* useDelTableCallback(
|
|
4008
|
-
* tableId: Id
|
|
4007
|
+
* useDelTableCallback<Parameter>(
|
|
4008
|
+
* tableId: Id | GetId<Parameter>,
|
|
4009
4009
|
* storeOrStoreId?: StoreOrStoreId,
|
|
4010
4010
|
* then?: (store: Store) => void,
|
|
4011
4011
|
* thenDeps?: React.DependencyList,
|
|
4012
|
-
* ):
|
|
4012
|
+
* ): ParameterizedCallback<Parameter>;
|
|
4013
4013
|
* ```
|
|
4014
4014
|
*
|
|
4015
4015
|
* This hook is useful, for example, when creating an event handler that will
|
|
4016
|
-
* delete data in
|
|
4016
|
+
* delete data in the Store. In this case, the parameter will likely be the
|
|
4017
|
+
* event, so that you can use data from it as part of the deletion.
|
|
4017
4018
|
*
|
|
4018
4019
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
4019
4020
|
* set of dependencies) which will be called just after the Store has been
|
|
@@ -4023,7 +4024,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4023
4024
|
* The Store to which the callback will make the deletion (indicated by the
|
|
4024
4025
|
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
4025
4026
|
* dependency for the callback.
|
|
4026
|
-
* @param tableId The Id of the Table in the Store
|
|
4027
|
+
* @param tableId The Id of the Table in the Store to delete, or a GetId
|
|
4028
|
+
* function that will return it.
|
|
4027
4029
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
4028
4030
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
4029
4031
|
* reference.
|
|
@@ -4031,8 +4033,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4031
4033
|
* to the Store.
|
|
4032
4034
|
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
4033
4035
|
* which, if any change, result in the regeneration of the callback. This
|
|
4034
|
-
* parameter defaults to an empty array.
|
|
4035
|
-
*
|
|
4036
|
+
* parameter defaults to an empty array. Also use this to indicate the
|
|
4037
|
+
* dependencies of an GetId function if used as the tableId argument.
|
|
4038
|
+
* @returns A parameterized callback for subsequent use.
|
|
4036
4039
|
* @example
|
|
4037
4040
|
* This example uses the useDelTableCallback hook to create an event handler
|
|
4038
4041
|
* which deletes from the Store when the `span` element is clicked.
|
|
@@ -4071,31 +4074,35 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4071
4074
|
* @category Store hooks
|
|
4072
4075
|
* @since v1.0.0
|
|
4073
4076
|
*/
|
|
4074
|
-
useDelTableCallback: <
|
|
4075
|
-
|
|
4077
|
+
useDelTableCallback: <
|
|
4078
|
+
Parameter,
|
|
4079
|
+
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
4080
|
+
>(
|
|
4081
|
+
tableId: TableId | GetId<Schemas, Parameter, TableId>,
|
|
4076
4082
|
storeOrStoreId?: StoreOrStoreId<Schemas>,
|
|
4077
4083
|
then?: (store: Store<Schemas>) => void,
|
|
4078
4084
|
thenDeps?: React.DependencyList,
|
|
4079
|
-
) =>
|
|
4085
|
+
) => ParameterizedCallback<Parameter>;
|
|
4080
4086
|
|
|
4081
4087
|
/**
|
|
4082
|
-
* The useDelRowCallback hook returns a callback that can be used
|
|
4083
|
-
* single Row from a Table.
|
|
4088
|
+
* The useDelRowCallback hook returns a parameterized callback that can be used
|
|
4089
|
+
* to remove a single Row from a Table.
|
|
4084
4090
|
*
|
|
4085
4091
|
* This has schema-based typing. The following is a simplified representation:
|
|
4086
4092
|
*
|
|
4087
4093
|
* ```ts override
|
|
4088
|
-
* useDelRowCallback(
|
|
4089
|
-
* tableId: Id
|
|
4090
|
-
* rowId: Id
|
|
4094
|
+
* useDelRowCallback<Parameter>(
|
|
4095
|
+
* tableId: Id | GetId<Parameter>,
|
|
4096
|
+
* rowId: Id | GetId<Parameter>,
|
|
4091
4097
|
* storeOrStoreId?: StoreOrStoreId,
|
|
4092
4098
|
* then?: (store: Store) => void,
|
|
4093
4099
|
* thenDeps?: React.DependencyList,
|
|
4094
|
-
* ):
|
|
4100
|
+
* ): ParameterizedCallback<Parameter>;
|
|
4095
4101
|
* ```
|
|
4096
4102
|
*
|
|
4097
4103
|
* This hook is useful, for example, when creating an event handler that will
|
|
4098
|
-
* delete data in
|
|
4104
|
+
* delete data in the Store. In this case, the parameter will likely be the
|
|
4105
|
+
* event, so that you can use data from it as part of the deletion.
|
|
4099
4106
|
*
|
|
4100
4107
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
4101
4108
|
* set of dependencies) which will be called just after the Store has been
|
|
@@ -4105,8 +4112,10 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4105
4112
|
* The Store to which the callback will make the deletion (indicated by the
|
|
4106
4113
|
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
4107
4114
|
* dependency for the callback.
|
|
4108
|
-
* @param tableId The Id of the Table in the Store
|
|
4109
|
-
*
|
|
4115
|
+
* @param tableId The Id of the Table in the Store, or a GetId function that
|
|
4116
|
+
* will return it.
|
|
4117
|
+
* @param rowId The Id of the Row in the Table to delete, or a GetId function
|
|
4118
|
+
* that will return it.
|
|
4110
4119
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
4111
4120
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
4112
4121
|
* reference.
|
|
@@ -4114,8 +4123,10 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4114
4123
|
* to the Store.
|
|
4115
4124
|
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
4116
4125
|
* which, if any change, result in the regeneration of the callback. This
|
|
4117
|
-
* parameter defaults to an empty array.
|
|
4118
|
-
*
|
|
4126
|
+
* parameter defaults to an empty array. Also use this to indicate the
|
|
4127
|
+
* dependencies of any GetId functions if used as the tableId or rowId
|
|
4128
|
+
* arguments.
|
|
4129
|
+
* @returns A parameterized callback for subsequent use.
|
|
4119
4130
|
* @example
|
|
4120
4131
|
* This example uses the useDelRowCallback hook to create an event handler which
|
|
4121
4132
|
* deletes from the Store when the `span` element is clicked.
|
|
@@ -4154,34 +4165,35 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4154
4165
|
* @category Store hooks
|
|
4155
4166
|
* @since v1.0.0
|
|
4156
4167
|
*/
|
|
4157
|
-
useDelRowCallback: <TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
4158
|
-
tableId: TableId,
|
|
4159
|
-
rowId: Id,
|
|
4168
|
+
useDelRowCallback: <Parameter, TableId extends TableIdFromSchema<Schemas[0]>>(
|
|
4169
|
+
tableId: TableId | GetId<Schemas, Parameter, TableId>,
|
|
4170
|
+
rowId: Id | GetId<Schemas, Parameter, Id>,
|
|
4160
4171
|
storeOrStoreId?: StoreOrStoreId<Schemas>,
|
|
4161
4172
|
then?: (store: Store<Schemas>) => void,
|
|
4162
4173
|
thenDeps?: React.DependencyList,
|
|
4163
|
-
) =>
|
|
4174
|
+
) => ParameterizedCallback<Parameter>;
|
|
4164
4175
|
|
|
4165
4176
|
/**
|
|
4166
|
-
* The useDelCellCallback hook returns a callback that can be used
|
|
4167
|
-
* single Cell from a Row.
|
|
4177
|
+
* The useDelCellCallback hook returns a parameterized callback that can be used
|
|
4178
|
+
* to remove a single Cell from a Row.
|
|
4168
4179
|
*
|
|
4169
4180
|
* This has schema-based typing. The following is a simplified representation:
|
|
4170
4181
|
*
|
|
4171
4182
|
* ```ts override
|
|
4172
|
-
* useDelCellCallback(
|
|
4173
|
-
* tableId: Id
|
|
4174
|
-
* rowId: Id
|
|
4175
|
-
* cellId: Id
|
|
4183
|
+
* useDelCellCallback<Parameter>(
|
|
4184
|
+
* tableId: Id | GetId<Parameter>,
|
|
4185
|
+
* rowId: Id | GetId<Parameter>,
|
|
4186
|
+
* cellId: Id | GetId<Parameter>,
|
|
4176
4187
|
* forceDel?: boolean,
|
|
4177
4188
|
* storeOrStoreId?: StoreOrStoreId,
|
|
4178
4189
|
* then?: (store: Store) => void,
|
|
4179
4190
|
* thenDeps?: React.DependencyList,
|
|
4180
|
-
* ):
|
|
4191
|
+
* ): ParameterizedCallback<Parameter>;
|
|
4181
4192
|
* ```
|
|
4182
4193
|
*
|
|
4183
4194
|
* This hook is useful, for example, when creating an event handler that will
|
|
4184
|
-
* delete data in
|
|
4195
|
+
* delete data in the Store. In this case, the parameter will likely be the
|
|
4196
|
+
* event, so that you can use data from it as part of the deletion.
|
|
4185
4197
|
*
|
|
4186
4198
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
4187
4199
|
* set of dependencies) which will be called just after the Store has been
|
|
@@ -4191,9 +4203,12 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4191
4203
|
* The Store to which the callback will make the deletion (indicated by the
|
|
4192
4204
|
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
4193
4205
|
* dependency for the callback.
|
|
4194
|
-
* @param tableId The Id of the Table in the Store
|
|
4195
|
-
*
|
|
4196
|
-
* @param
|
|
4206
|
+
* @param tableId The Id of the Table in the Store, or a GetId function that
|
|
4207
|
+
* will return it.
|
|
4208
|
+
* @param rowId The Id of the Row in the Table, or a GetId function that will
|
|
4209
|
+
* return it.
|
|
4210
|
+
* @param cellId The Id of the Cell in the Row to delete, or a GetId function
|
|
4211
|
+
* that will return it.
|
|
4197
4212
|
* @param forceDel An optional flag to indicate that the whole Row should be
|
|
4198
4213
|
* deleted, even if a TablesSchema provides a default value for this Cell.
|
|
4199
4214
|
* Defaults to `false`.
|
|
@@ -4204,8 +4219,10 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4204
4219
|
* to the Store.
|
|
4205
4220
|
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
4206
4221
|
* which, if any change, result in the regeneration of the callback. This
|
|
4207
|
-
* parameter defaults to an empty array.
|
|
4208
|
-
*
|
|
4222
|
+
* parameter defaults to an empty array. Also use this to indicate the
|
|
4223
|
+
* dependencies of any GetId functions if used as the tableId, rowId, or cellId
|
|
4224
|
+
* arguments.
|
|
4225
|
+
* @returns A parameterized callback for subsequent use.
|
|
4209
4226
|
* @example
|
|
4210
4227
|
* This example uses the useDelCellCallback hook to create an event handler
|
|
4211
4228
|
* which deletes from the Store when the `span` element is clicked.
|
|
@@ -4250,17 +4267,18 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4250
4267
|
* @since v1.0.0
|
|
4251
4268
|
*/
|
|
4252
4269
|
useDelCellCallback: <
|
|
4270
|
+
Parameter,
|
|
4253
4271
|
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
4254
4272
|
CellId extends CellIdFromSchema<Schemas[0], TableId>,
|
|
4255
4273
|
>(
|
|
4256
|
-
tableId: TableId,
|
|
4257
|
-
rowId: Id,
|
|
4258
|
-
cellId: CellId,
|
|
4274
|
+
tableId: TableId | GetId<Schemas, Parameter, TableId>,
|
|
4275
|
+
rowId: Id | GetId<Schemas, Parameter, Id>,
|
|
4276
|
+
cellId: CellId | GetId<Schemas, Parameter, CellId>,
|
|
4259
4277
|
forceDel?: boolean,
|
|
4260
4278
|
storeOrStoreId?: StoreOrStoreId<Schemas>,
|
|
4261
4279
|
then?: (store: Store<Schemas>) => void,
|
|
4262
4280
|
thenDeps?: React.DependencyList,
|
|
4263
|
-
) =>
|
|
4281
|
+
) => ParameterizedCallback<Parameter>;
|
|
4264
4282
|
|
|
4265
4283
|
/**
|
|
4266
4284
|
* The useDelValuesCallback hook returns a callback that can be used to remove
|
|
@@ -4341,22 +4359,23 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4341
4359
|
) => Callback;
|
|
4342
4360
|
|
|
4343
4361
|
/**
|
|
4344
|
-
* The useDelValueCallback hook returns a callback that can be
|
|
4345
|
-
* single Value from a Store.
|
|
4362
|
+
* The useDelValueCallback hook returns a parameterized callback that can be
|
|
4363
|
+
* used to remove a single Value from a Store.
|
|
4346
4364
|
*
|
|
4347
4365
|
* This has schema-based typing. The following is a simplified representation:
|
|
4348
4366
|
*
|
|
4349
4367
|
* ```ts override
|
|
4350
|
-
* useDelValueCallback(
|
|
4351
|
-
* valueId: Id
|
|
4368
|
+
* useDelValueCallback<Parameter>(
|
|
4369
|
+
* valueId: Id | GetId<Parameter>,
|
|
4352
4370
|
* storeOrStoreId?: StoreOrStoreId,
|
|
4353
4371
|
* then?: (store: Store) => void,
|
|
4354
4372
|
* thenDeps?: React.DependencyList,
|
|
4355
|
-
* ):
|
|
4373
|
+
* ): ParameterizedCallback<Parameter>;
|
|
4356
4374
|
* ```
|
|
4357
4375
|
*
|
|
4358
4376
|
* This hook is useful, for example, when creating an event handler that will
|
|
4359
|
-
* delete data in
|
|
4377
|
+
* delete data in the Store. In this case, the parameter will likely be the
|
|
4378
|
+
* event, so that you can use data from it as part of the deletion.
|
|
4360
4379
|
*
|
|
4361
4380
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
4362
4381
|
* set of dependencies) which will be called just after the Store has been
|
|
@@ -4366,7 +4385,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4366
4385
|
* The Store to which the callback will make the deletion (indicated by the
|
|
4367
4386
|
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
4368
4387
|
* dependency for the callback.
|
|
4369
|
-
* @param valueId The Id of the Value in the Store
|
|
4388
|
+
* @param valueId The Id of the Value in the Store to delete, or a GetId
|
|
4389
|
+
* function that will return it.
|
|
4370
4390
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
4371
4391
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
4372
4392
|
* reference.
|
|
@@ -4374,8 +4394,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4374
4394
|
* to the Store.
|
|
4375
4395
|
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
4376
4396
|
* which, if any change, result in the regeneration of the callback. This
|
|
4377
|
-
* parameter defaults to an empty array.
|
|
4378
|
-
*
|
|
4397
|
+
* parameter defaults to an empty array. Also use this to indicate the
|
|
4398
|
+
* dependencies of a GetId function if used as the valueId argument.
|
|
4399
|
+
* @returns A parameterized callback for subsequent use.
|
|
4379
4400
|
* @example
|
|
4380
4401
|
* This example uses the useDelValueCallback hook to create an event handler
|
|
4381
4402
|
* which deletes from the Store when the `span` element is clicked.
|
|
@@ -4414,12 +4435,15 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
4414
4435
|
* @category Store hooks
|
|
4415
4436
|
* @since v3.0.0
|
|
4416
4437
|
*/
|
|
4417
|
-
useDelValueCallback: <
|
|
4418
|
-
|
|
4438
|
+
useDelValueCallback: <
|
|
4439
|
+
Parameter,
|
|
4440
|
+
ValueId extends ValueIdFromSchema<Schemas[1]>,
|
|
4441
|
+
>(
|
|
4442
|
+
valueId: ValueId | GetId<Schemas, Parameter, ValueId>,
|
|
4419
4443
|
storeOrStoreId?: StoreOrStoreId<Schemas>,
|
|
4420
4444
|
then?: (store: Store<Schemas>) => void,
|
|
4421
4445
|
thenDeps?: React.DependencyList,
|
|
4422
|
-
) =>
|
|
4446
|
+
) => ParameterizedCallback<Parameter>;
|
|
4423
4447
|
|
|
4424
4448
|
/**
|
|
4425
4449
|
* The useHasTablesListener hook registers a listener function with the Store
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=n=>null==n,e=(e,l,t)=>n(e)?null==t?void 0:t():l(e),l=(n,e,l)=>n.slice(e,l),t=n=>n.length,r=(n,e)=>n.forEach(e),s=(n,...e)=>n.push(...e),u=Object.freeze,o=n=>{var e;return null!=(e=null==n?void 0:n.size)?e:0},d=(a=o,n=>{return e=(n,e)=>n+a(e),i(n).reduce(e,0);var e});var a;const c=e=>n(e)||0==o(e),i=n=>{var e;return[...null!=(e=null==n?void 0:n.values())?e:[]]},v=(n,e)=>null==n?void 0:n.forEach(e),h=(n,e)=>null==n?void 0:n.delete(e),f=n=>new Map(n),g=n=>{var e;return[...null!=(e=null==n?void 0:n.keys())?e:[]]},S=(n,e)=>null==n?void 0:n.get(e),y=(e,l,t)=>n(t)?(h(e,l),e):null==e?void 0:e.set(l,t),k=(n,e,l,t)=>{var r,s,u;return s=e,null!=(u=null==(r=n)?void 0:r.has(s))&&u?null==t||t(S(n,e)):y(n,e,l()),S(n,e)},p=(n,l,r,s,u=0)=>e((r?k:S)(n,l[u],u>t(l)-2?r:f),(e=>{if(u>t(l)-2)return(null==s?void 0:s(e))&&y(n,l[u]),e;const o=p(e,l,r,s,u+1);return c(e)&&y(n,l[u]),o})),I=e=>new Set(Array.isArray(e)||n(e)?e:[e]),b=/^\d+$/,w=/\/([^?]*)/;exports.createWsServer=a=>{const i=f(),z=f(),L=f(),[m,x,A]=(l=>{let u;const[o,d]=(()=>{const n=[];let e=0;return[l=>{var t;return null!=(t=l?n.shift():null)?t:""+e++},e=>{b.test(e)&&t(n)<1e3&&s(n,e)}]})(),a=f();return[(n,e,l,t=[],r=(()=>[]))=>{null!=u||(u=C);const s=o(1);var d,c;return y(a,s,[n,e,l,t,r]),c=s,null==(d=p(e,null!=l?l:[""],I))||d.add(c),s},(n,e,...l)=>r(((n,e=[""])=>{const l=[],u=(n,o)=>o==t(e)?s(l,n):null===e[o]?v(n,(n=>u(n,o+1))):r([e[o],null],(e=>u(S(n,e),o+1)));return u(n,0),l})(n,e),(n=>v(n,(n=>S(a,n)[0](u,...null!=e?e:[],...l))))),n=>e(S(a,n),(([,e,l])=>(p(e,null!=l?l:[""],void 0,(e=>(h(e,n),c(e)?1:0))),y(a,n),d(n),l))),l=>e(S(a,l),(([e,,l=[],s,o])=>{const d=(...a)=>{var c,i;const v=t(a);v==t(l)?e(u,...a,...o(a)):n(l[v])?r(null!=(i=null==(c=s[v])?void 0:c.call(s,...a))?i:[],(n=>d(...a,n))):d(...a,l[v])};d()}))]})();a.on("connection",((n,t)=>{var r;return e(null==(r=t.url)?void 0:r.match(w),(([,r])=>e(t.headers["sec-websocket-key"],(e=>{const t=k(L,r,f);y(t,e,n),1==t.size&&x(i,void 0,
|
|
1
|
+
"use strict";const n=n=>null==n,e=(e,l,t)=>n(e)?null==t?void 0:t():l(e),l=(n,e,l)=>n.slice(e,l),t=n=>n.length,r=(n,e)=>n.forEach(e),s=(n,...e)=>n.push(...e),u=Object.freeze,o=n=>{var e;return null!=(e=null==n?void 0:n.size)?e:0},d=(a=o,n=>{return e=(n,e)=>n+a(e),i(n).reduce(e,0);var e});var a;const c=e=>n(e)||0==o(e),i=n=>{var e;return[...null!=(e=null==n?void 0:n.values())?e:[]]},v=(n,e)=>null==n?void 0:n.forEach(e),h=(n,e)=>null==n?void 0:n.delete(e),f=n=>new Map(n),g=n=>{var e;return[...null!=(e=null==n?void 0:n.keys())?e:[]]},S=(n,e)=>null==n?void 0:n.get(e),y=(e,l,t)=>n(t)?(h(e,l),e):null==e?void 0:e.set(l,t),k=(n,e,l,t)=>{var r,s,u;return s=e,null!=(u=null==(r=n)?void 0:r.has(s))&&u?null==t||t(S(n,e)):y(n,e,l()),S(n,e)},p=(n,l,r,s,u=0)=>e((r?k:S)(n,l[u],u>t(l)-2?r:f),(e=>{if(u>t(l)-2)return(null==s?void 0:s(e))&&y(n,l[u]),e;const o=p(e,l,r,s,u+1);return c(e)&&y(n,l[u]),o})),I=e=>new Set(Array.isArray(e)||n(e)?e:[e]),b=/^\d+$/,w=/\/([^?]*)/;exports.createWsServer=a=>{const i=f(),z=f(),L=f(),[m,x,A]=(l=>{let u;const[o,d]=(()=>{const n=[];let e=0;return[l=>{var t;return null!=(t=l?n.shift():null)?t:""+e++},e=>{b.test(e)&&t(n)<1e3&&s(n,e)}]})(),a=f();return[(n,e,l,t=[],r=(()=>[]))=>{null!=u||(u=C);const s=o(1);var d,c;return y(a,s,[n,e,l,t,r]),c=s,null==(d=p(e,null!=l?l:[""],I))||d.add(c),s},(n,e,...l)=>r(((n,e=[""])=>{const l=[],u=(n,o)=>o==t(e)?s(l,n):null===e[o]?v(n,(n=>u(n,o+1))):r([e[o],null],(e=>u(S(n,e),o+1)));return u(n,0),l})(n,e),(n=>v(n,(n=>S(a,n)[0](u,...null!=e?e:[],...l))))),n=>e(S(a,n),(([,e,l])=>(p(e,null!=l?l:[""],void 0,(e=>(h(e,n),c(e)?1:0))),y(a,n),d(n),l))),l=>e(S(a,l),(([e,,l=[],s,o])=>{const d=(...a)=>{var c,i;const v=t(a);v==t(l)?e(u,...a,...o(a)):n(l[v])?r(null!=(i=null==(c=s[v])?void 0:c.call(s,...a))?i:[],(n=>d(...a,n))):d(...a,l[v])};d()}))]})();a.on("connection",((n,t)=>{var r;return e(null==(r=t.url)?void 0:r.match(w),(([,r])=>e(t.headers["sec-websocket-key"],(e=>{const t=k(L,r,f);y(t,e,n),1==t.size&&x(i,void 0,r,1),x(z,[r],e,1),n.on("message",(n=>{var r;const s=n.toString("utf8"),u=s.indexOf("\n");if(-1!==u){const n=l(s,0,u),d=l(s,u+1);""===n?(o=(n,l)=>n!=e?l.send(e+"\n"+d):0,v(t,((n,e)=>o(e,n)))):null==(r=S(t,n))||r.send(e+"\n"+d)}var o})),n.on("close",(()=>{h(t,e),x(z,[r],e,-1),c(t)&&(h(L,r),x(i,void 0,r,-1))}))}))))}));const C={getWebSocketServer:()=>a,getPathIds:()=>g(L),getClientIds:n=>g(S(L,n)),addPathIdsListener:n=>m(n,i),addClientIdsListener:(n,e)=>m(e,z,[n]),delListener:n=>(A(n),C),getStats:()=>({paths:o(L),clients:d(L)}),destroy:()=>{a.close(),L.clear()}};return u(C)};
|
|
Binary file
|