@ngrx/signals 19.0.0-beta.0 → 19.0.0-rc.0

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.
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
13
+ var __read = (this && this.__read) || function (o, n) {
14
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15
+ if (!m) return o;
16
+ var i = m.call(o), r, ar = [], e;
17
+ try {
18
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
+ }
20
+ catch (error) { e = { error: error }; }
21
+ finally {
22
+ try {
23
+ if (r && !r.done && (m = i["return"])) m.call(i);
24
+ }
25
+ finally { if (e) throw e.error; }
26
+ }
27
+ return ar;
28
+ };
29
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
30
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31
+ if (ar || !(i in from)) {
32
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33
+ ar[i] = from[i];
34
+ }
35
+ }
36
+ return to.concat(ar || Array.prototype.slice.call(from));
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.migrate = migrate;
40
+ exports.default = default_1;
41
+ var schematics_1 = require("@angular-devkit/schematics");
42
+ var schematics_core_1 = require("../../schematics-core");
43
+ var visitors_1 = require("../../schematics-core/utility/visitors");
44
+ var ts = require("typescript");
45
+ function migratedToEntityProps(sourceFile) {
46
+ var changes = [];
47
+ (0, visitors_1.visitImportDeclaration)(sourceFile, function (importDeclaration, moduleName) {
48
+ if (moduleName !== '@ngrx/signals/entities') {
49
+ return;
50
+ }
51
+ (0, visitors_1.visitImportSpecifier)(importDeclaration, function (importSpecifier) {
52
+ if (importSpecifier.name.getText() === 'EntityComputed') {
53
+ changes.push((0, schematics_core_1.createReplaceChange)(sourceFile, importSpecifier, importSpecifier.getText(), 'EntityProps'));
54
+ (0, visitors_1.visitTypeReference)(sourceFile, function (type) {
55
+ if (type.typeName.getText() === 'EntityComputed') {
56
+ changes.push((0, schematics_core_1.createReplaceChange)(sourceFile, type, type.typeName.getText(), 'EntityProps'));
57
+ }
58
+ });
59
+ }
60
+ if (importSpecifier.name.getText() === 'NamedEntityComputed') {
61
+ changes.push((0, schematics_core_1.createReplaceChange)(sourceFile, importSpecifier, importSpecifier.getText(), 'NamedEntityProps'));
62
+ (0, visitors_1.visitTypeReference)(sourceFile, function (typeReference) {
63
+ if (typeReference.typeName.getText() === 'NamedEntityComputed') {
64
+ changes.push((0, schematics_core_1.createReplaceChange)(sourceFile, typeReference.typeName, typeReference.typeName.getText(), 'NamedEntityProps'));
65
+ }
66
+ });
67
+ }
68
+ });
69
+ });
70
+ return changes;
71
+ }
72
+ function migrateToPropsInSignalStoreFeatureType(sourceFile) {
73
+ var changes = [];
74
+ (0, visitors_1.visitTypeReference)(sourceFile, function (typeReference) {
75
+ if (typeReference.typeName.getText() !== 'SignalStoreFeature') {
76
+ return;
77
+ }
78
+ (0, visitors_1.visitTypeLiteral)(typeReference, function (typeLiteral) {
79
+ var e_1, _a;
80
+ var typeLiteralChildren = typeLiteral.members;
81
+ try {
82
+ for (var typeLiteralChildren_1 = __values(typeLiteralChildren), typeLiteralChildren_1_1 = typeLiteralChildren_1.next(); !typeLiteralChildren_1_1.done; typeLiteralChildren_1_1 = typeLiteralChildren_1.next()) {
83
+ var propertySignature = typeLiteralChildren_1_1.value;
84
+ if (ts.isPropertySignature(propertySignature)) {
85
+ if (propertySignature.name.getText() === 'computed') {
86
+ changes.push((0, schematics_core_1.createReplaceChange)(sourceFile, propertySignature.name, 'computed', 'props'));
87
+ }
88
+ }
89
+ }
90
+ }
91
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
92
+ finally {
93
+ try {
94
+ if (typeLiteralChildren_1_1 && !typeLiteralChildren_1_1.done && (_a = typeLiteralChildren_1.return)) _a.call(typeLiteralChildren_1);
95
+ }
96
+ finally { if (e_1) throw e_1.error; }
97
+ }
98
+ });
99
+ });
100
+ return changes;
101
+ }
102
+ function migrateToPropsInSignalStoreFeatureWithObjectLiteral(objectLiteral, sourceFile) {
103
+ var computedKey = objectLiteral.properties
104
+ .filter(ts.isPropertyAssignment)
105
+ .find(function (property) { return property.name.getText() === 'computed'; });
106
+ if (computedKey) {
107
+ return [(0, schematics_core_1.createReplaceChange)(sourceFile, computedKey, 'computed', 'props')];
108
+ }
109
+ return [];
110
+ }
111
+ function migrateToPropsInSignalStoreFeatureWithCallExpression(callExpression, sourceFile) {
112
+ var _a;
113
+ if (callExpression.expression.getText() === 'type') {
114
+ var typeArgument = (_a = callExpression.typeArguments) === null || _a === void 0 ? void 0 : _a.at(0);
115
+ if (typeArgument && ts.isTypeLiteralNode(typeArgument)) {
116
+ var computedKey = typeArgument.members
117
+ .filter(ts.isPropertySignature)
118
+ .find(function (propertySignature) { return propertySignature.name.getText() === 'computed'; });
119
+ if (computedKey) {
120
+ return [
121
+ (0, schematics_core_1.createReplaceChange)(sourceFile, computedKey, 'computed', 'props'),
122
+ ];
123
+ }
124
+ }
125
+ }
126
+ return [];
127
+ }
128
+ function migrateToPropsInSignalStoreFeatureFunction(sourceFile) {
129
+ var changes = [];
130
+ (0, visitors_1.visitCallExpression)(sourceFile, function (callExpression) {
131
+ if (callExpression.expression.getText() !== 'signalStoreFeature') {
132
+ return;
133
+ }
134
+ var objectLiteralOrCallExpression = callExpression.arguments[0];
135
+ if (!objectLiteralOrCallExpression) {
136
+ return;
137
+ }
138
+ if (ts.isObjectLiteralExpression(objectLiteralOrCallExpression)) {
139
+ changes.push.apply(changes, __spreadArray([], __read(migrateToPropsInSignalStoreFeatureWithObjectLiteral(objectLiteralOrCallExpression, sourceFile)), false));
140
+ }
141
+ else if (ts.isCallExpression(objectLiteralOrCallExpression)) {
142
+ changes.push.apply(changes, __spreadArray([], __read(migrateToPropsInSignalStoreFeatureWithCallExpression(objectLiteralOrCallExpression, sourceFile)), false));
143
+ }
144
+ });
145
+ return changes;
146
+ }
147
+ function migrate() {
148
+ return function (tree, ctx) {
149
+ (0, schematics_core_1.visitTSSourceFiles)(tree, function (sourceFile) {
150
+ var entityPropsChanges = migratedToEntityProps(sourceFile);
151
+ var propsInSignalStoreFeatureTypeChanges = migrateToPropsInSignalStoreFeatureType(sourceFile);
152
+ var propsInSignalStoreFeatureFunctionChanges = migrateToPropsInSignalStoreFeatureFunction(sourceFile);
153
+ var changes = __spreadArray(__spreadArray(__spreadArray([], __read(entityPropsChanges), false), __read(propsInSignalStoreFeatureTypeChanges), false), __read(propsInSignalStoreFeatureFunctionChanges), false);
154
+ (0, schematics_core_1.commitChanges)(tree, sourceFile.fileName, changes);
155
+ if (entityPropsChanges.length) {
156
+ ctx.logger.info("[@ngrx/signals] Renamed '(Named)EntityComputed' to '(Named)EntityProps' in ".concat(sourceFile.fileName));
157
+ }
158
+ if (propsInSignalStoreFeatureTypeChanges.length) {
159
+ ctx.logger.info("[@ngrx/signals] Renamed 'computed' to 'props' in SignalStoreFeature<> in ".concat(sourceFile.fileName));
160
+ }
161
+ if (propsInSignalStoreFeatureFunctionChanges.length) {
162
+ ctx.logger.info("[@ngrx/signals] Renamed 'computed' to 'props' in signalStoreFeature() in ".concat(sourceFile.fileName));
163
+ }
164
+ });
165
+ };
166
+ }
167
+ function default_1() {
168
+ return (0, schematics_1.chain)([migrate()]);
169
+ }
170
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/signals/migrations/19_0_0-rc_0-props/index.ts"],"names":[],"mappings":";;;;;;;;;;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C;YACD,IAAI,wCAAwC,CAAC,MAAM,EAAE,CAAC;gBACpD,GAAG,CAAC,MAAM,CAAC,IAAI,CACb,mFAA4E,UAAU,CAAC,QAAQ,CAAE,CAClG,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED;IACE,OAAO,IAAA,kBAAK,EAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import {\n chain,\n Rule,\n SchematicContext,\n Tree,\n} from '@angular-devkit/schematics';\nimport {\n Change,\n commitChanges,\n createReplaceChange,\n visitTSSourceFiles,\n} from '../../schematics-core';\nimport {\n visitCallExpression,\n visitImportDeclaration,\n visitImportSpecifier,\n visitTypeLiteral,\n visitTypeReference,\n} from '../../schematics-core/utility/visitors';\nimport * as ts from 'typescript';\n\nfunction migratedToEntityProps(sourceFile: ts.SourceFile) {\n const changes: Change[] = [];\n visitImportDeclaration(sourceFile, (importDeclaration, moduleName) => {\n if (moduleName !== '@ngrx/signals/entities') {\n return;\n }\n\n visitImportSpecifier(importDeclaration, (importSpecifier) => {\n if (importSpecifier.name.getText() === 'EntityComputed') {\n changes.push(\n createReplaceChange(\n sourceFile,\n importSpecifier,\n importSpecifier.getText(),\n 'EntityProps'\n )\n );\n\n visitTypeReference(sourceFile, (type) => {\n if (type.typeName.getText() === 'EntityComputed') {\n changes.push(\n createReplaceChange(\n sourceFile,\n type,\n type.typeName.getText(),\n 'EntityProps'\n )\n );\n }\n });\n }\n\n if (importSpecifier.name.getText() === 'NamedEntityComputed') {\n changes.push(\n createReplaceChange(\n sourceFile,\n importSpecifier,\n importSpecifier.getText(),\n 'NamedEntityProps'\n )\n );\n\n visitTypeReference(sourceFile, (typeReference) => {\n if (typeReference.typeName.getText() === 'NamedEntityComputed') {\n changes.push(\n createReplaceChange(\n sourceFile,\n typeReference.typeName,\n typeReference.typeName.getText(),\n 'NamedEntityProps'\n )\n );\n }\n });\n }\n });\n });\n\n return changes;\n}\n\nfunction migrateToPropsInSignalStoreFeatureType(\n sourceFile: ts.SourceFile\n): Change[] {\n const changes: Change[] = [];\n visitTypeReference(sourceFile, (typeReference) => {\n if (typeReference.typeName.getText() !== 'SignalStoreFeature') {\n return;\n }\n\n visitTypeLiteral(typeReference, (typeLiteral) => {\n const typeLiteralChildren = typeLiteral.members;\n for (const propertySignature of typeLiteralChildren) {\n if (ts.isPropertySignature(propertySignature)) {\n if (propertySignature.name.getText() === 'computed') {\n changes.push(\n createReplaceChange(\n sourceFile,\n propertySignature.name,\n 'computed',\n 'props'\n )\n );\n }\n }\n }\n });\n });\n\n return changes;\n}\n\nfunction migrateToPropsInSignalStoreFeatureWithObjectLiteral(\n objectLiteral: ts.ObjectLiteralExpression,\n sourceFile: ts.SourceFile\n): Change[] {\n const computedKey = objectLiteral.properties\n .filter(ts.isPropertyAssignment)\n .find((property) => property.name.getText() === 'computed');\n if (computedKey) {\n return [createReplaceChange(sourceFile, computedKey, 'computed', 'props')];\n }\n\n return [];\n}\n\nfunction migrateToPropsInSignalStoreFeatureWithCallExpression(\n callExpression: ts.CallExpression,\n sourceFile: ts.SourceFile\n): Change[] {\n if (callExpression.expression.getText() === 'type') {\n const typeArgument = callExpression.typeArguments?.at(0);\n\n if (typeArgument && ts.isTypeLiteralNode(typeArgument)) {\n const computedKey = typeArgument.members\n .filter(ts.isPropertySignature)\n .find(\n (propertySignature) => propertySignature.name.getText() === 'computed'\n );\n\n if (computedKey) {\n return [\n createReplaceChange(sourceFile, computedKey, 'computed', 'props'),\n ];\n }\n }\n }\n\n return [];\n}\n\nfunction migrateToPropsInSignalStoreFeatureFunction(\n sourceFile: ts.SourceFile\n): Change[] {\n const changes: Change[] = [];\n visitCallExpression(sourceFile, (callExpression) => {\n if (callExpression.expression.getText() !== 'signalStoreFeature') {\n return;\n }\n\n const objectLiteralOrCallExpression = callExpression.arguments[0];\n if (!objectLiteralOrCallExpression) {\n return;\n }\n\n if (ts.isObjectLiteralExpression(objectLiteralOrCallExpression)) {\n changes.push(\n ...migrateToPropsInSignalStoreFeatureWithObjectLiteral(\n objectLiteralOrCallExpression,\n sourceFile\n )\n );\n } else if (ts.isCallExpression(objectLiteralOrCallExpression)) {\n changes.push(\n ...migrateToPropsInSignalStoreFeatureWithCallExpression(\n objectLiteralOrCallExpression,\n sourceFile\n )\n );\n }\n });\n\n return changes;\n}\n\nexport function migrate(): Rule {\n return (tree: Tree, ctx: SchematicContext) => {\n visitTSSourceFiles(tree, (sourceFile) => {\n const entityPropsChanges = migratedToEntityProps(sourceFile);\n const propsInSignalStoreFeatureTypeChanges =\n migrateToPropsInSignalStoreFeatureType(sourceFile);\n const propsInSignalStoreFeatureFunctionChanges =\n migrateToPropsInSignalStoreFeatureFunction(sourceFile);\n const changes = [\n ...entityPropsChanges,\n ...propsInSignalStoreFeatureTypeChanges,\n ...propsInSignalStoreFeatureFunctionChanges,\n ];\n\n commitChanges(tree, sourceFile.fileName, changes);\n\n if (entityPropsChanges.length) {\n ctx.logger.info(\n `[@ngrx/signals] Renamed '(Named)EntityComputed' to '(Named)EntityProps' in ${sourceFile.fileName}`\n );\n }\n if (propsInSignalStoreFeatureTypeChanges.length) {\n ctx.logger.info(\n `[@ngrx/signals] Renamed 'computed' to 'props' in SignalStoreFeature<> in ${sourceFile.fileName}`\n );\n }\n if (propsInSignalStoreFeatureFunctionChanges.length) {\n ctx.logger.info(\n `[@ngrx/signals] Renamed 'computed' to 'props' in signalStoreFeature() in ${sourceFile.fileName}`\n );\n }\n });\n };\n}\n\nexport default function (): Rule {\n return chain([migrate()]);\n}\n"]}
@@ -10,6 +10,11 @@
10
10
  "description": "Replace StateSignal usages with WritableStateSource",
11
11
  "version": "18.0.0-rc.3",
12
12
  "factory": "./18_0_0-rc_3-writablestatesource/index"
13
+ },
14
+ "19_0_0-rc_0-props": {
15
+ "description": "Replace several properties with a single props object",
16
+ "version": "19.0.0-rc.0",
17
+ "factory": "./19_0_0-rc_0-props/index"
13
18
  }
14
19
  }
15
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngrx/signals",
3
- "version": "19.0.0-beta.0",
3
+ "version": "19.0.0-rc.0",
4
4
  "description": "Reactive Store and Set of Utilities for Angular Signals",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.platformVersion = void 0;
4
- exports.platformVersion = '^19.0.0-beta.0';
4
+ exports.platformVersion = '^19.0.0-rc.0';
5
5
  //# sourceMappingURL=libs-version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"libs-version.js","sourceRoot":"","sources":["../../../../../modules/signals/schematics-core/utility/libs-version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,gBAAgB,CAAC","sourcesContent":["export const platformVersion = '^19.0.0-beta.0';\n"]}
1
+ {"version":3,"file":"libs-version.js","sourceRoot":"","sources":["../../../../../modules/signals/schematics-core/utility/libs-version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,cAAc,CAAC","sourcesContent":["export const platformVersion = '^19.0.0-rc.0';\n"]}
@@ -61,6 +61,11 @@ exports.visitNgModuleExports = visitNgModuleExports;
61
61
  exports.visitComponents = visitComponents;
62
62
  exports.visitNgModules = visitNgModules;
63
63
  exports.visitDecorator = visitDecorator;
64
+ exports.visitImportDeclaration = visitImportDeclaration;
65
+ exports.visitImportSpecifier = visitImportSpecifier;
66
+ exports.visitTypeReference = visitTypeReference;
67
+ exports.visitTypeLiteral = visitTypeLiteral;
68
+ exports.visitCallExpression = visitCallExpression;
64
69
  var ts = require("typescript");
65
70
  var core_1 = require("@angular-devkit/core");
66
71
  function visitTSSourceFiles(tree, visitor) {
@@ -179,9 +184,81 @@ function visitDecorator(sourceFile, decoratorName, callback) {
179
184
  callback(classDeclarationNode, arg);
180
185
  });
181
186
  }
187
+ function visitImportDeclaration(node, callback) {
188
+ if (ts.isImportDeclaration(node)) {
189
+ var moduleSpecifier = node.moduleSpecifier.getText();
190
+ var moduleName = moduleSpecifier.replaceAll('"', '').replaceAll("'", '');
191
+ callback(node, moduleName);
192
+ }
193
+ ts.forEachChild(node, function (child) {
194
+ visitImportDeclaration(child, callback);
195
+ });
196
+ }
197
+ function visitImportSpecifier(node, callback) {
198
+ var e_2, _a, e_3, _b;
199
+ var importClause = node.importClause;
200
+ if (!importClause) {
201
+ return;
202
+ }
203
+ var importClauseChildren = importClause.getChildren();
204
+ try {
205
+ for (var importClauseChildren_1 = __values(importClauseChildren), importClauseChildren_1_1 = importClauseChildren_1.next(); !importClauseChildren_1_1.done; importClauseChildren_1_1 = importClauseChildren_1.next()) {
206
+ var namedImport = importClauseChildren_1_1.value;
207
+ if (ts.isNamedImports(namedImport)) {
208
+ var namedImportChildren = namedImport.elements;
209
+ try {
210
+ for (var namedImportChildren_1 = (e_3 = void 0, __values(namedImportChildren)), namedImportChildren_1_1 = namedImportChildren_1.next(); !namedImportChildren_1_1.done; namedImportChildren_1_1 = namedImportChildren_1.next()) {
211
+ var importSpecifier = namedImportChildren_1_1.value;
212
+ if (ts.isImportSpecifier(importSpecifier)) {
213
+ callback(importSpecifier);
214
+ }
215
+ }
216
+ }
217
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
218
+ finally {
219
+ try {
220
+ if (namedImportChildren_1_1 && !namedImportChildren_1_1.done && (_b = namedImportChildren_1.return)) _b.call(namedImportChildren_1);
221
+ }
222
+ finally { if (e_3) throw e_3.error; }
223
+ }
224
+ }
225
+ }
226
+ }
227
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
228
+ finally {
229
+ try {
230
+ if (importClauseChildren_1_1 && !importClauseChildren_1_1.done && (_a = importClauseChildren_1.return)) _a.call(importClauseChildren_1);
231
+ }
232
+ finally { if (e_2) throw e_2.error; }
233
+ }
234
+ }
235
+ function visitTypeReference(node, callback) {
236
+ if (ts.isTypeReferenceNode(node)) {
237
+ callback(node);
238
+ }
239
+ ts.forEachChild(node, function (child) {
240
+ visitTypeReference(child, callback);
241
+ });
242
+ }
243
+ function visitTypeLiteral(node, callback) {
244
+ if (ts.isTypeLiteralNode(node)) {
245
+ callback(node);
246
+ }
247
+ ts.forEachChild(node, function (child) {
248
+ visitTypeLiteral(child, callback);
249
+ });
250
+ }
251
+ function visitCallExpression(node, callback) {
252
+ if (ts.isCallExpression(node)) {
253
+ callback(node);
254
+ }
255
+ ts.forEachChild(node, function (child) {
256
+ visitCallExpression(child, callback);
257
+ });
258
+ }
182
259
  function visit(directory) {
183
- var _a, _b, path, entry, content, source, e_2_1, _c, _d, path, e_3_1;
184
- var e_2, _e, e_3, _f;
260
+ var _a, _b, path, entry, content, source, e_4_1, _c, _d, path, e_5_1;
261
+ var e_4, _e, e_5, _f;
185
262
  return __generator(this, function (_g) {
186
263
  switch (_g.label) {
187
264
  case 0:
@@ -205,14 +282,14 @@ function visit(directory) {
205
282
  return [3 /*break*/, 1];
206
283
  case 4: return [3 /*break*/, 7];
207
284
  case 5:
208
- e_2_1 = _g.sent();
209
- e_2 = { error: e_2_1 };
285
+ e_4_1 = _g.sent();
286
+ e_4 = { error: e_4_1 };
210
287
  return [3 /*break*/, 7];
211
288
  case 6:
212
289
  try {
213
290
  if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
214
291
  }
215
- finally { if (e_2) throw e_2.error; }
292
+ finally { if (e_4) throw e_4.error; }
216
293
  return [7 /*endfinally*/];
217
294
  case 7:
218
295
  _g.trys.push([7, 12, 13, 14]);
@@ -233,14 +310,14 @@ function visit(directory) {
233
310
  return [3 /*break*/, 8];
234
311
  case 11: return [3 /*break*/, 14];
235
312
  case 12:
236
- e_3_1 = _g.sent();
237
- e_3 = { error: e_3_1 };
313
+ e_5_1 = _g.sent();
314
+ e_5 = { error: e_5_1 };
238
315
  return [3 /*break*/, 14];
239
316
  case 13:
240
317
  try {
241
318
  if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
242
319
  }
243
- finally { if (e_3) throw e_3.error; }
320
+ finally { if (e_5) throw e_5.error; }
244
321
  return [7 /*endfinally*/];
245
322
  case 14: return [2 /*return*/];
246
323
  }
@@ -1 +1 @@
1
- {"version":3,"file":"visitors.js","sourceRoot":"","sources":["../../../../../modules/signals/schematics-core/utility/visitors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,gDAcC;AAED,wCAoEC;AAED,oDAQC;AAED,oDAQC;AA0BD,0CAQC;AAED,wCAQC;AAED,wCA4CC;AAtMD,+BAAiC;AACjC,6CAA0D;AAG1D,SAAgB,kBAAkB,CAChC,IAAU,EACV,OAIuB;;IAEvB,IAAI,MAAM,GAAuB,SAAS,CAAC;;QAC3C,KAAyB,IAAA,KAAA,SAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,gBAAA,4BAAE,CAAC;YAAvC,IAAM,UAAU,WAAA;YACnB,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;;;;;;;;;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,cAAc,CAC5B,IAAU,EACV,OAQS;IAET,kBAAkB,CAAC,IAAI,EAAE,UAAC,MAAM;QAC9B,eAAe,CAAC,MAAM,EAAE,UAAC,CAAC,EAAE,uBAAuB;YACjD,EAAE,CAAC,YAAY,CAAC,uBAAuB,EAAE,SAAS,aAAa,CAAC,CAAC;gBAC/D,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC1D,IACE,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU;wBAC1B,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,CAAC,EACrC,CAAC;wBACD,4EAA4E;wBAC5E,oCAAoC;wBACpC,IAAM,gBAAgB,GAAG,CA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QAAQ,CAAA;;;;gBAA1B,IAAI;qBACT,CAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA,EAA/C,wBAA+C;gBAC3C,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;qBAC/B,KAAK,EAAL,wBAAK;gBACD,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;gBACxB,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAChC,KAAK,CAAC,IAAI,EACV,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EACzC,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,IAAI,CACL,CAAC;gBACF,qBAAM,MAAM,EAAA;;gBAAZ,SAAY,CAAC;;;;;;;;;;;;;;;;;;gBAKA,KAAA,SAAA,SAAS,CAAC,OAAO,CAAA;;;;gBAAzB,IAAI;gBACb,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;oBAC5B,yBAAS;gBACX,CAAC;gBAED,sBAAA,SAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA,EAAA;;gBAAjC,SAAiC,CAAC;;;;;;;;;;;;;;;;;;;CAErC","sourcesContent":["import * as ts from 'typescript';\nimport { normalize, resolve } from '@angular-devkit/core';\nimport { Tree, DirEntry } from '@angular-devkit/schematics';\n\nexport function visitTSSourceFiles<Result = void>(\n tree: Tree,\n visitor: (\n sourceFile: ts.SourceFile,\n tree: Tree,\n result?: Result\n ) => Result | undefined\n): Result | undefined {\n let result: Result | undefined = undefined;\n for (const sourceFile of visit(tree.root)) {\n result = visitor(sourceFile, tree, result);\n }\n\n return result;\n}\n\nexport function visitTemplates(\n tree: Tree,\n visitor: (\n template: {\n fileName: string;\n content: string;\n inline: boolean;\n start: number;\n },\n tree: Tree\n ) => void\n): void {\n visitTSSourceFiles(tree, (source) => {\n visitComponents(source, (_, decoratorExpressionNode) => {\n ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {\n if (ts.isPropertyAssignment(n) && ts.isIdentifier(n.name)) {\n if (\n n.name.text === 'template' &&\n ts.isStringLiteralLike(n.initializer)\n ) {\n // Need to add an offset of one to the start because the template quotes are\n // not part of the template content.\n const templateStartIdx = n.initializer.getStart() + 1;\n visitor(\n {\n fileName: source.fileName,\n content: n.initializer.text,\n inline: true,\n start: templateStartIdx,\n },\n tree\n );\n return;\n } else if (\n n.name.text === 'templateUrl' &&\n ts.isStringLiteralLike(n.initializer)\n ) {\n const parts = normalize(source.fileName).split('/').slice(0, -1);\n const templatePath = resolve(\n normalize(parts.join('/')),\n normalize(n.initializer.text)\n );\n if (!tree.exists(templatePath)) {\n return;\n }\n\n const fileContent = tree.read(templatePath);\n if (!fileContent) {\n return;\n }\n\n visitor(\n {\n fileName: templatePath,\n content: fileContent.toString(),\n inline: false,\n start: 0,\n },\n tree\n );\n return;\n }\n }\n\n ts.forEachChild(n, findTemplates);\n });\n });\n });\n}\n\nexport function visitNgModuleImports(\n sourceFile: ts.SourceFile,\n callback: (\n importNode: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void\n) {\n visitNgModuleProperty(sourceFile, callback, 'imports');\n}\n\nexport function visitNgModuleExports(\n sourceFile: ts.SourceFile,\n callback: (\n exportNode: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void\n) {\n visitNgModuleProperty(sourceFile, callback, 'exports');\n}\n\nfunction visitNgModuleProperty(\n sourceFile: ts.SourceFile,\n callback: (\n nodes: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void,\n property: string\n) {\n visitNgModules(sourceFile, (_, decoratorExpressionNode) => {\n ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {\n if (\n ts.isPropertyAssignment(n) &&\n ts.isIdentifier(n.name) &&\n n.name.text === property &&\n ts.isArrayLiteralExpression(n.initializer)\n ) {\n callback(n, n.initializer.elements);\n return;\n }\n\n ts.forEachChild(n, findTemplates);\n });\n });\n}\nexport function visitComponents(\n sourceFile: ts.SourceFile,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n visitDecorator(sourceFile, 'Component', callback);\n}\n\nexport function visitNgModules(\n sourceFile: ts.SourceFile,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n visitDecorator(sourceFile, 'NgModule', callback);\n}\n\nexport function visitDecorator(\n sourceFile: ts.SourceFile,\n decoratorName: string,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n ts.forEachChild(sourceFile, function findClassDeclaration(node) {\n if (!ts.isClassDeclaration(node)) {\n ts.forEachChild(node, findClassDeclaration);\n }\n\n const classDeclarationNode = node as ts.ClassDeclaration;\n const decorators = ts.getDecorators(classDeclarationNode);\n\n if (!decorators || !decorators.length) {\n return;\n }\n\n const componentDecorator = decorators.find((d) => {\n return (\n ts.isCallExpression(d.expression) &&\n ts.isIdentifier(d.expression.expression) &&\n d.expression.expression.text === decoratorName\n );\n });\n\n if (!componentDecorator) {\n return;\n }\n\n const { expression } = componentDecorator;\n if (!ts.isCallExpression(expression)) {\n return;\n }\n\n const [arg] = expression.arguments;\n if (!arg || !ts.isObjectLiteralExpression(arg)) {\n return;\n }\n\n callback(classDeclarationNode, arg);\n });\n}\n\nfunction* visit(directory: DirEntry): IterableIterator<ts.SourceFile> {\n for (const path of directory.subfiles) {\n if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {\n const entry = directory.file(path);\n if (entry) {\n const content = entry.content;\n const source = ts.createSourceFile(\n entry.path,\n content.toString().replace(/^\\uFEFF/, ''),\n ts.ScriptTarget.Latest,\n true\n );\n yield source;\n }\n }\n }\n\n for (const path of directory.subdirs) {\n if (path === 'node_modules') {\n continue;\n }\n\n yield* visit(directory.dir(path));\n }\n}\n"]}
1
+ {"version":3,"file":"visitors.js","sourceRoot":"","sources":["../../../../../modules/signals/schematics-core/utility/visitors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,gDAcC;AAED,wCAoEC;AAED,oDAQC;AAED,oDAQC;AA0BD,0CAQC;AAED,wCAQC;AAED,wCA4CC;AAED,wDAiBC;AAED,oDAoBC;AAED,gDAWC;AAED,4CAWC;AAED,kDAWC;AAtRD,+BAAiC;AACjC,6CAA0D;AAG1D,SAAgB,kBAAkB,CAChC,IAAU,EACV,OAIuB;;IAEvB,IAAI,MAAM,GAAuB,SAAS,CAAC;;QAC3C,KAAyB,IAAA,KAAA,SAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,gBAAA,4BAAE,CAAC;YAAvC,IAAM,UAAU,WAAA;YACnB,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;;;;;;;;;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,cAAc,CAC5B,IAAU,EACV,OAQS;IAET,kBAAkB,CAAC,IAAI,EAAE,UAAC,MAAM;QAC9B,eAAe,CAAC,MAAM,EAAE,UAAC,CAAC,EAAE,uBAAuB;YACjD,EAAE,CAAC,YAAY,CAAC,uBAAuB,EAAE,SAAS,aAAa,CAAC,CAAC;gBAC/D,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC1D,IACE,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU;wBAC1B,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,CAAC,EACrC,CAAC;wBACD,4EAA4E;wBAC5E,oCAAoC;wBACpC,IAA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ACV,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EACzC,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,IAAI,CACL,CAAC;gBACF,qBAAM,MAAM,EAAA;;gBAAZ,SAAY,CAAC;;;;;;;;;;;;;;;;;;gBAKA,KAAA,SAAA,SAAS,CAAC,OAAO,CAAA;;;;gBAAzB,IAAI;gBACb,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;oBAC5B,yBAAS;gBACX,CAAC;gBAED,sBAAA,SAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA,EAAA;;gBAAjC,SAAiC,CAAC;;;;;;;;;;;;;;;;;;;CAErC","sourcesContent":["import * as ts from 'typescript';\nimport { normalize, resolve } from '@angular-devkit/core';\nimport { Tree, DirEntry } from '@angular-devkit/schematics';\n\nexport function visitTSSourceFiles<Result = void>(\n tree: Tree,\n visitor: (\n sourceFile: ts.SourceFile,\n tree: Tree,\n result?: Result\n ) => Result | undefined\n): Result | undefined {\n let result: Result | undefined = undefined;\n for (const sourceFile of visit(tree.root)) {\n result = visitor(sourceFile, tree, result);\n }\n\n return result;\n}\n\nexport function visitTemplates(\n tree: Tree,\n visitor: (\n template: {\n fileName: string;\n content: string;\n inline: boolean;\n start: number;\n },\n tree: Tree\n ) => void\n): void {\n visitTSSourceFiles(tree, (source) => {\n visitComponents(source, (_, decoratorExpressionNode) => {\n ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {\n if (ts.isPropertyAssignment(n) && ts.isIdentifier(n.name)) {\n if (\n n.name.text === 'template' &&\n ts.isStringLiteralLike(n.initializer)\n ) {\n // Need to add an offset of one to the start because the template quotes are\n // not part of the template content.\n const templateStartIdx = n.initializer.getStart() + 1;\n visitor(\n {\n fileName: source.fileName,\n content: n.initializer.text,\n inline: true,\n start: templateStartIdx,\n },\n tree\n );\n return;\n } else if (\n n.name.text === 'templateUrl' &&\n ts.isStringLiteralLike(n.initializer)\n ) {\n const parts = normalize(source.fileName).split('/').slice(0, -1);\n const templatePath = resolve(\n normalize(parts.join('/')),\n normalize(n.initializer.text)\n );\n if (!tree.exists(templatePath)) {\n return;\n }\n\n const fileContent = tree.read(templatePath);\n if (!fileContent) {\n return;\n }\n\n visitor(\n {\n fileName: templatePath,\n content: fileContent.toString(),\n inline: false,\n start: 0,\n },\n tree\n );\n return;\n }\n }\n\n ts.forEachChild(n, findTemplates);\n });\n });\n });\n}\n\nexport function visitNgModuleImports(\n sourceFile: ts.SourceFile,\n callback: (\n importNode: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void\n) {\n visitNgModuleProperty(sourceFile, callback, 'imports');\n}\n\nexport function visitNgModuleExports(\n sourceFile: ts.SourceFile,\n callback: (\n exportNode: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void\n) {\n visitNgModuleProperty(sourceFile, callback, 'exports');\n}\n\nfunction visitNgModuleProperty(\n sourceFile: ts.SourceFile,\n callback: (\n nodes: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void,\n property: string\n) {\n visitNgModules(sourceFile, (_, decoratorExpressionNode) => {\n ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {\n if (\n ts.isPropertyAssignment(n) &&\n ts.isIdentifier(n.name) &&\n n.name.text === property &&\n ts.isArrayLiteralExpression(n.initializer)\n ) {\n callback(n, n.initializer.elements);\n return;\n }\n\n ts.forEachChild(n, findTemplates);\n });\n });\n}\nexport function visitComponents(\n sourceFile: ts.SourceFile,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n visitDecorator(sourceFile, 'Component', callback);\n}\n\nexport function visitNgModules(\n sourceFile: ts.SourceFile,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n visitDecorator(sourceFile, 'NgModule', callback);\n}\n\nexport function visitDecorator(\n sourceFile: ts.SourceFile,\n decoratorName: string,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n ts.forEachChild(sourceFile, function findClassDeclaration(node) {\n if (!ts.isClassDeclaration(node)) {\n ts.forEachChild(node, findClassDeclaration);\n }\n\n const classDeclarationNode = node as ts.ClassDeclaration;\n const decorators = ts.getDecorators(classDeclarationNode);\n\n if (!decorators || !decorators.length) {\n return;\n }\n\n const componentDecorator = decorators.find((d) => {\n return (\n ts.isCallExpression(d.expression) &&\n ts.isIdentifier(d.expression.expression) &&\n d.expression.expression.text === decoratorName\n );\n });\n\n if (!componentDecorator) {\n return;\n }\n\n const { expression } = componentDecorator;\n if (!ts.isCallExpression(expression)) {\n return;\n }\n\n const [arg] = expression.arguments;\n if (!arg || !ts.isObjectLiteralExpression(arg)) {\n return;\n }\n\n callback(classDeclarationNode, arg);\n });\n}\n\nexport function visitImportDeclaration(\n node: ts.Node,\n callback: (\n importDeclaration: ts.ImportDeclaration,\n moduleName?: string\n ) => void\n) {\n if (ts.isImportDeclaration(node)) {\n const moduleSpecifier = node.moduleSpecifier.getText();\n const moduleName = moduleSpecifier.replaceAll('\"', '').replaceAll(\"'\", '');\n\n callback(node, moduleName);\n }\n\n ts.forEachChild(node, (child) => {\n visitImportDeclaration(child, callback);\n });\n}\n\nexport function visitImportSpecifier(\n node: ts.ImportDeclaration,\n callback: (importSpecifier: ts.ImportSpecifier) => void\n) {\n const { importClause } = node;\n if (!importClause) {\n return;\n }\n\n const importClauseChildren = importClause.getChildren();\n for (const namedImport of importClauseChildren) {\n if (ts.isNamedImports(namedImport)) {\n const namedImportChildren = namedImport.elements;\n for (const importSpecifier of namedImportChildren) {\n if (ts.isImportSpecifier(importSpecifier)) {\n callback(importSpecifier);\n }\n }\n }\n }\n}\n\nexport function visitTypeReference(\n node: ts.Node,\n callback: (typeReference: ts.TypeReferenceNode) => void\n) {\n if (ts.isTypeReferenceNode(node)) {\n callback(node);\n }\n\n ts.forEachChild(node, (child) => {\n visitTypeReference(child, callback);\n });\n}\n\nexport function visitTypeLiteral(\n node: ts.Node,\n callback: (typeLiteral: ts.TypeLiteralNode) => void\n) {\n if (ts.isTypeLiteralNode(node)) {\n callback(node);\n }\n\n ts.forEachChild(node, (child) => {\n visitTypeLiteral(child, callback);\n });\n}\n\nexport function visitCallExpression(\n node: ts.Node,\n callback: (callExpression: ts.CallExpression) => void\n) {\n if (ts.isCallExpression(node)) {\n callback(node);\n }\n\n ts.forEachChild(node, (child) => {\n visitCallExpression(child, callback);\n });\n}\n\nfunction* visit(directory: DirEntry): IterableIterator<ts.SourceFile> {\n for (const path of directory.subfiles) {\n if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {\n const entry = directory.file(path);\n if (entry) {\n const content = entry.content;\n const source = ts.createSourceFile(\n entry.path,\n content.toString().replace(/^\\uFEFF/, ''),\n ts.ScriptTarget.Latest,\n true\n );\n yield source;\n }\n }\n }\n\n for (const path of directory.subdirs) {\n if (path === 'node_modules') {\n continue;\n }\n\n yield* visit(directory.dir(path));\n }\n}\n"]}
package/src/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { deepComputed } from './deep-computed';
2
2
  export { DeepSignal } from './deep-signal';
3
+ export { signalMethod } from './signal-method';
3
4
  export { signalState, SignalState } from './signal-state';
4
5
  export { signalStore } from './signal-store';
5
6
  export { signalStoreFeature, type } from './signal-store-feature';
@@ -9,4 +10,5 @@ export { Prettify } from './ts-helpers';
9
10
  export { withComputed } from './with-computed';
10
11
  export { withHooks } from './with-hooks';
11
12
  export { withMethods } from './with-methods';
13
+ export { withProps } from './with-props';
12
14
  export { withState } from './with-state';
@@ -0,0 +1,8 @@
1
+ import { EffectRef, Injector, Signal } from '@angular/core';
2
+ type SignalMethod<Input> = ((input: Input | Signal<Input>, config?: {
3
+ injector?: Injector;
4
+ }) => EffectRef) & EffectRef;
5
+ export declare function signalMethod<Input>(processingFn: (value: Input) => void, config?: {
6
+ injector?: Injector;
7
+ }): SignalMethod<Input>;
8
+ export {};
@@ -2,7 +2,7 @@ import { EmptyFeatureResult, SignalStoreFeature, SignalStoreFeatureResult } from
2
2
  import { Prettify } from './ts-helpers';
3
3
  type PrettifyFeatureResult<Result extends SignalStoreFeatureResult> = Prettify<{
4
4
  state: Prettify<Result['state']>;
5
- computed: Prettify<Result['computed']>;
5
+ props: Prettify<Result['props']>;
6
6
  methods: Prettify<Result['methods']>;
7
7
  }>;
8
8
  export declare function signalStoreFeature<F1 extends SignalStoreFeatureResult>(f1: SignalStoreFeature<EmptyFeatureResult, F1>): SignalStoreFeature<EmptyFeatureResult, F1>;
@@ -11,20 +11,20 @@ export type SignalStoreHooks = {
11
11
  onInit?: () => void;
12
12
  onDestroy?: () => void;
13
13
  };
14
- export type InnerSignalStore<State extends object = object, ComputedSignals extends SignalsDictionary = SignalsDictionary, Methods extends MethodsDictionary = MethodsDictionary> = {
14
+ export type InnerSignalStore<State extends object = object, Props extends object = object, Methods extends MethodsDictionary = MethodsDictionary> = {
15
15
  stateSignals: StateSignals<State>;
16
- computedSignals: ComputedSignals;
16
+ props: Props;
17
17
  methods: Methods;
18
18
  hooks: SignalStoreHooks;
19
19
  } & WritableStateSource<State>;
20
20
  export type SignalStoreFeatureResult = {
21
21
  state: object;
22
- computed: SignalsDictionary;
22
+ props: object;
23
23
  methods: MethodsDictionary;
24
24
  };
25
25
  export type EmptyFeatureResult = {
26
26
  state: {};
27
- computed: {};
27
+ props: {};
28
28
  methods: {};
29
29
  };
30
- export type SignalStoreFeature<Input extends SignalStoreFeatureResult = SignalStoreFeatureResult, Output extends SignalStoreFeatureResult = SignalStoreFeatureResult> = (store: InnerSignalStore<Input['state'], Input['computed'], Input['methods']>) => InnerSignalStore<Output['state'], Output['computed'], Output['methods']>;
30
+ export type SignalStoreFeature<Input extends SignalStoreFeatureResult = SignalStoreFeatureResult, Output extends SignalStoreFeatureResult = SignalStoreFeatureResult> = (store: InnerSignalStore<Input['state'], Input['props'], Input['methods']>) => InnerSignalStore<Output['state'], Output['props'], Output['methods']>;
@@ -2,7 +2,7 @@ import { Type } from '@angular/core';
2
2
  import { StateSource, WritableStateSource } from './state-source';
3
3
  import { EmptyFeatureResult, InnerSignalStore, SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
4
4
  import { OmitPrivate, Prettify } from './ts-helpers';
5
- type SignalStoreMembers<FeatureResult extends SignalStoreFeatureResult> = Prettify<OmitPrivate<StateSignals<FeatureResult['state']> & FeatureResult['computed'] & FeatureResult['methods']>>;
5
+ type SignalStoreMembers<FeatureResult extends SignalStoreFeatureResult> = Prettify<OmitPrivate<StateSignals<FeatureResult['state']> & FeatureResult['props'] & FeatureResult['methods']>>;
6
6
  export declare function signalStore<F1 extends SignalStoreFeatureResult>(f1: SignalStoreFeature<EmptyFeatureResult, F1>): Type<SignalStoreMembers<F1> & StateSource<Prettify<OmitPrivate<F1['state']>>>>;
7
7
  export declare function signalStore<F1 extends SignalStoreFeatureResult, F2 extends SignalStoreFeatureResult, R extends SignalStoreFeatureResult = F1 & F2>(f1: SignalStoreFeature<EmptyFeatureResult, F1>, f2: SignalStoreFeature<{} & F1, F2>): Type<SignalStoreMembers<R> & StateSource<Prettify<OmitPrivate<R['state']>>>>;
8
8
  export declare function signalStore<F1 extends SignalStoreFeatureResult, F2 extends SignalStoreFeatureResult, F3 extends SignalStoreFeatureResult, R extends SignalStoreFeatureResult = F1 & F2 & F3>(f1: SignalStoreFeature<EmptyFeatureResult, F1>, f2: SignalStoreFeature<{} & F1, F2>, f3: SignalStoreFeature<F1 & F2, F3>): Type<SignalStoreMembers<R> & StateSource<Prettify<OmitPrivate<R['state']>>>>;
@@ -1,9 +1,11 @@
1
+ type NonRecord = Iterable<any> | WeakSet<any> | WeakMap<any, any> | Promise<any> | Date | Error | RegExp | ArrayBuffer | DataView | Function;
1
2
  export type Prettify<T> = {
2
3
  [K in keyof T]: T[K];
3
4
  } & {};
4
- export type IsRecord<T> = T extends object ? T extends unknown[] ? false : T extends Set<unknown> ? false : T extends Map<unknown, unknown> ? false : T extends Function ? false : true : false;
5
+ export type IsRecord<T> = T extends object ? T extends NonRecord ? false : true : false;
5
6
  export type IsUnknownRecord<T> = string extends keyof T ? true : number extends keyof T ? true : false;
6
7
  export type IsKnownRecord<T> = IsRecord<T> extends true ? IsUnknownRecord<T> extends true ? false : true : false;
7
8
  export type OmitPrivate<T> = {
8
9
  [K in keyof T as K extends `_${string}` ? never : K]: T[K];
9
10
  };
11
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { SignalsDictionary, SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
2
2
  import { Prettify } from './ts-helpers';
3
- export declare function withComputed<Input extends SignalStoreFeatureResult, ComputedSignals extends SignalsDictionary>(signalsFactory: (store: Prettify<StateSignals<Input['state']> & Input['computed']>) => ComputedSignals): SignalStoreFeature<Input, {
3
+ export declare function withComputed<Input extends SignalStoreFeatureResult, ComputedSignals extends SignalsDictionary>(signalsFactory: (store: Prettify<StateSignals<Input['state']> & Input['props']>) => ComputedSignals): SignalStoreFeature<Input, {
4
4
  state: {};
5
- computed: ComputedSignals;
5
+ props: ComputedSignals;
6
6
  methods: {};
7
7
  }>;
@@ -1,8 +1,8 @@
1
1
  import { WritableStateSource } from './state-source';
2
2
  import { EmptyFeatureResult, SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
3
3
  import { Prettify } from './ts-helpers';
4
- type HookFn<Input extends SignalStoreFeatureResult> = (store: Prettify<StateSignals<Input['state']> & Input['computed'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => void;
5
- type HooksFactory<Input extends SignalStoreFeatureResult> = (store: Prettify<StateSignals<Input['state']> & Input['computed'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => {
4
+ type HookFn<Input extends SignalStoreFeatureResult> = (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => void;
5
+ type HooksFactory<Input extends SignalStoreFeatureResult> = (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => {
6
6
  onInit?: () => void;
7
7
  onDestroy?: () => void;
8
8
  };
@@ -1,8 +1,8 @@
1
1
  import { WritableStateSource } from './state-source';
2
2
  import { MethodsDictionary, SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
3
3
  import { Prettify } from './ts-helpers';
4
- export declare function withMethods<Input extends SignalStoreFeatureResult, Methods extends MethodsDictionary>(methodsFactory: (store: Prettify<StateSignals<Input['state']> & Input['computed'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => Methods): SignalStoreFeature<Input, {
4
+ export declare function withMethods<Input extends SignalStoreFeatureResult, Methods extends MethodsDictionary>(methodsFactory: (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => Methods): SignalStoreFeature<Input, {
5
5
  state: {};
6
- computed: {};
6
+ props: {};
7
7
  methods: Methods;
8
8
  }>;
@@ -0,0 +1,8 @@
1
+ import { WritableStateSource } from './state-source';
2
+ import { SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
3
+ import { Prettify } from './ts-helpers';
4
+ export declare function withProps<Input extends SignalStoreFeatureResult, Props extends object>(propsFactory: (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => Props): SignalStoreFeature<Input, {
5
+ state: {};
6
+ props: Props;
7
+ methods: {};
8
+ }>;
@@ -1,11 +1,11 @@
1
1
  import { EmptyFeatureResult, SignalStoreFeature } from './signal-store-models';
2
2
  export declare function withState<State extends object>(stateFactory: () => State): SignalStoreFeature<EmptyFeatureResult, {
3
3
  state: State;
4
- computed: {};
4
+ props: {};
5
5
  methods: {};
6
6
  }>;
7
7
  export declare function withState<State extends object>(state: State): SignalStoreFeature<EmptyFeatureResult, {
8
8
  state: State;
9
- computed: {};
9
+ props: {};
10
10
  methods: {};
11
11
  }>;