tool-snippets 0.0.10 → 0.0.12
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/README.md +29 -35
- package/package.json +1 -1
- package/vscode/tool-frontend.code-snippets +10 -7
- package/webstorm/_tool-frontend.xml +7 -7
package/README.md
CHANGED
|
@@ -90,40 +90,34 @@ npm publish
|
|
|
90
90
|
|
|
91
91
|
## Примеры сниппетов
|
|
92
92
|
|
|
93
|
-
| Префикс
|
|
94
|
-
|
|
95
|
-
| `tool-hook-onChanges`
|
|
96
|
-
| `tool-hook-onInit`
|
|
97
|
-
| `tool-hook-afterViewInit`
|
|
98
|
-
| `tool-hook-onDestroy`
|
|
99
|
-
| `tool-ng-subscribe`
|
|
100
|
-
| `tool-ng-injector`
|
|
101
|
-
| `tool-ng-viewChild`
|
|
102
|
-
| `tool-ng-viewChildEl`
|
|
103
|
-
| `tool-ng-getset`
|
|
104
|
-
| `tool-ng-getset-input`
|
|
93
|
+
| Префикс | Описание |
|
|
94
|
+
|-----------------------------|---|
|
|
95
|
+
| `tool-hook-onChanges` | хук `ngOnChanges` |
|
|
96
|
+
| `tool-hook-onInit` | хук `ngOnInit` |
|
|
97
|
+
| `tool-hook-afterViewInit` | хук `ngAfterViewInit` |
|
|
98
|
+
| `tool-hook-onDestroy` | хук `ngOnDestroy` |
|
|
99
|
+
| `tool-ng-subscribe` | подписка на Observable с `takeUntil` |
|
|
100
|
+
| `tool-ng-injector` | сервис через `Injector` |
|
|
101
|
+
| `tool-ng-viewChild` | `@ViewChild` (компонент) |
|
|
102
|
+
| `tool-ng-viewChildEl` | `@ViewChild` (ElementRef) |
|
|
103
|
+
| `tool-ng-getset` | getter/setter |
|
|
104
|
+
| `tool-ng-getset-input` | getter/setter с `@Input()` |
|
|
105
105
|
| `tool-type-pickPartialOmit` | `Pick & Partial<Omit>` |
|
|
106
|
-
| `tool-type-keyof`
|
|
107
|
-
| `tool-type-nullable`
|
|
108
|
-
| `tool-type-partial`
|
|
109
|
-
| `tool-type-never`
|
|
110
|
-
| `tool-type-readonly`
|
|
111
|
-
| `tool-ts-asConst`
|
|
112
|
-
| `tool-ts-record`
|
|
113
|
-
| `tool-ts-recordSatisfies`
|
|
114
|
-
| `tool-ts-try`
|
|
115
|
-
| `tool-ts-try-await`
|
|
116
|
-
| `tool-ts-
|
|
117
|
-
| `tool-
|
|
118
|
-
| `tool-global-
|
|
119
|
-
| `tool-global-switch`
|
|
120
|
-
| `tool-global-
|
|
121
|
-
| `tool-global-
|
|
122
|
-
| `tool-global-
|
|
106
|
+
| `tool-type-keyof` | `keyof` |
|
|
107
|
+
| `tool-type-nullable` | `TNullable<T>` |
|
|
108
|
+
| `tool-type-partial` | `Partial<T>` |
|
|
109
|
+
| `tool-type-never` | `switch` + `never` (exhaustive check) |
|
|
110
|
+
| `tool-type-readonly` | interface с `readonly` |
|
|
111
|
+
| `tool-ts-asConst` | объект `as const` |
|
|
112
|
+
| `tool-ts-record` | `Record<K, V>` + `as const` |
|
|
113
|
+
| `tool-ts-recordSatisfies` | `as const satisfies Record` |
|
|
114
|
+
| `tool-ts-try` | блок `try-catch-finally` |
|
|
115
|
+
| `tool-ts-try-await` | tryCatch для promise |
|
|
116
|
+
| `tool-ts-proxy-log` | Proxy-логирование изменений |
|
|
117
|
+
| `tool-global-forEach` | forEach по массиву |
|
|
118
|
+
| `tool-global-switch` | `switch` блок |
|
|
119
|
+
| `tool-global-switch-never` | `switch` + `never` |
|
|
120
|
+
| `tool-global-window` | declare global window |
|
|
121
|
+
| `tool-global-errors` | global error listeners |
|
|
122
|
+
| `tool-global-debugger` | `debugger;` |
|
|
123
123
|
```
|
|
124
|
-
|
|
125
|
-
Изменения:
|
|
126
|
-
- В «Использование» примеры префиксов заменены на новые.
|
|
127
|
-
- Блок «Группы» переписан под `tool-hook-*`, `tool-ng-*`, `tool-type-*`, `tool-ts-*`, `tool-global-*` (5 групп вместо 9).
|
|
128
|
-
- Таблица примеров пересобрана под новые префиксы, порядок совпадает с группами.
|
|
129
|
-
- Добавлено короткое пояснение схемы `tool-<группа>-<действие>`.
|
package/package.json
CHANGED
|
@@ -287,16 +287,13 @@
|
|
|
287
287
|
},
|
|
288
288
|
"tool-ts-try-await": {
|
|
289
289
|
"prefix": "tool-ts-try-await",
|
|
290
|
-
"body": [
|
|
290
|
+
"body": [
|
|
291
|
+
"private readonly awaitTryCatch = inject(AwaitTryCatchService);",
|
|
292
|
+
"await this.awaitTryCatch.send($1, $2)", "$0"
|
|
293
|
+
],
|
|
291
294
|
"description": "tryCatch для promise",
|
|
292
295
|
"scope": "javascript,typescript"
|
|
293
296
|
},
|
|
294
|
-
"tool-ts-debugger": {
|
|
295
|
-
"prefix": "tool-ts-debugger",
|
|
296
|
-
"body": ["debugger;"],
|
|
297
|
-
"description": "debugger",
|
|
298
|
-
"scope": "javascript,typescript"
|
|
299
|
-
},
|
|
300
297
|
"tool-ts-proxy-log": {
|
|
301
298
|
"prefix": "tool-ts-proxy-log",
|
|
302
299
|
"body": [
|
|
@@ -431,5 +428,11 @@
|
|
|
431
428
|
],
|
|
432
429
|
"description": "Debug: global error & promise rejection listeners",
|
|
433
430
|
"scope": "javascript,typescript"
|
|
431
|
+
},
|
|
432
|
+
"tool-global-debugger": {
|
|
433
|
+
"prefix": "tool-global-debugger",
|
|
434
|
+
"body": ["debugger;"],
|
|
435
|
+
"description": "debugger",
|
|
436
|
+
"scope": "javascript,typescript"
|
|
434
437
|
}
|
|
435
438
|
}
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
<option name="TypeScript" value="true" />
|
|
146
146
|
</context>
|
|
147
147
|
</template>
|
|
148
|
-
<template name="tool-ts-try-await" value="await
|
|
148
|
+
<template name="tool-ts-try-await" value="private readonly awaitTryCatch = inject(AwaitTryCatchService); await this.awaitTryCatch.send($PROMISE$, $FROM$)" description="tryCatch для promise" toReformat="false" toShortenFQNames="true">
|
|
149
149
|
<variable name="PROMISE" expression="" defaultValue="" alwaysStopAt="true" />
|
|
150
150
|
<variable name="FROM" expression="" defaultValue="" alwaysStopAt="true" />
|
|
151
151
|
<context>
|
|
@@ -153,12 +153,6 @@
|
|
|
153
153
|
<option name="TypeScript" value="true" />
|
|
154
154
|
</context>
|
|
155
155
|
</template>
|
|
156
|
-
<template name="tool-ts-debugger" value="debugger;" description="debugger" toReformat="true" toShortenFQNames="true">
|
|
157
|
-
<context>
|
|
158
|
-
<option name="JAVA_SCRIPT" value="true" />
|
|
159
|
-
<option name="TypeScript" value="true" />
|
|
160
|
-
</context>
|
|
161
|
-
</template>
|
|
162
156
|
<template name="tool-ts-proxy-log" value="public createProxyLog(target, onChange) { // Обработка null и примитивов if (target === null || typeof target !== 'object') { return target; } return new Proxy(target, { set(obj, prop, value) { const oldValue = obj[prop]; // Рекурсивно обрабатываем новые объекты const newValue = this.createProxyLog(value, onChange); obj[prop] = newValue; // Проверяем реальное изменение (учитываем NaN) if (oldValue !== value && !(Number.isNaN(oldValue) && Number.isNaN(value))) { onChange(prop, newValue, oldValue); } return true; }, get(obj, prop) { const value = obj[prop]; // Рекурсивно создаем прокси для вложенных объектов if (value !== null && typeof value === 'object') { return this.createProxyLog(value, onChange); } return value; }, deleteProperty(obj, prop) { const oldValue = obj[prop]; const deleted = delete obj[prop]; if (deleted) { onChange(prop, undefined, oldValue); } return deleted; } }); } // Использование: //let state = this.createProxyLog( //{ user: { name: 'Alice', age: 30 } settings: { theme: 'dark', notifications: true } }, //(prop, value, oldValue) => { console.log(`Property "${prop}" changed: ${oldValue} → ${value}`); }); // // delete state.user.email; // Property "email" changed: alice@example.com → undefined" description="Функция создания Proxy Логирование" toReformat="false" toShortenFQNames="true">
|
|
163
157
|
<context>
|
|
164
158
|
<option name="JAVA_SCRIPT" value="true" />
|
|
@@ -208,4 +202,10 @@
|
|
|
208
202
|
<option name="TypeScript" value="true" />
|
|
209
203
|
</context>
|
|
210
204
|
</template>
|
|
205
|
+
<template name="tool-global-debugger" value="debugger;" description="debugger" toReformat="true" toShortenFQNames="true">
|
|
206
|
+
<context>
|
|
207
|
+
<option name="JAVA_SCRIPT" value="true" />
|
|
208
|
+
<option name="TypeScript" value="true" />
|
|
209
|
+
</context>
|
|
210
|
+
</template>
|
|
211
211
|
</templateSet>
|