@thomas-siegfried/tapout 0.0.1 → 0.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.
Files changed (52) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1207 -1205
  3. package/decorator-config.md +220 -0
  4. package/dist/wireParams.d.ts.map +1 -1
  5. package/dist/wireParams.js +27 -4
  6. package/dist/wireParams.js.map +1 -1
  7. package/llms.txt +360 -0
  8. package/package.json +57 -55
  9. package/src/applyBindings.ts +372 -372
  10. package/src/arrayToDomMapping.ts +300 -300
  11. package/src/attributeInterpolationMarkup.ts +91 -91
  12. package/src/bindingContext.ts +207 -207
  13. package/src/bindingEvent.ts +198 -198
  14. package/src/bindingProvider.ts +260 -260
  15. package/src/bindings.ts +963 -963
  16. package/src/compareArrays.ts +122 -122
  17. package/src/componentBinding.ts +318 -318
  18. package/src/componentDecorator.ts +62 -62
  19. package/src/components.ts +367 -367
  20. package/src/computed.ts +439 -439
  21. package/src/configure.ts +52 -52
  22. package/src/controlFlowBindings.ts +206 -206
  23. package/src/core.ts +60 -60
  24. package/src/decorators.ts +407 -407
  25. package/src/dependencyDetection.ts +76 -76
  26. package/src/disposable.ts +36 -36
  27. package/src/domData.ts +42 -42
  28. package/src/domNodeDisposal.ts +94 -94
  29. package/src/effects.ts +29 -29
  30. package/src/event.ts +173 -173
  31. package/src/expressionRewriting.ts +219 -219
  32. package/src/extenders.ts +102 -102
  33. package/src/filters.ts +91 -91
  34. package/src/index.ts +150 -150
  35. package/src/interpolationMarkup.ts +130 -130
  36. package/src/memoization.ts +71 -71
  37. package/src/namespacedBindings.ts +132 -132
  38. package/src/observable.ts +48 -48
  39. package/src/observableArray.ts +397 -397
  40. package/src/options.ts +25 -25
  41. package/src/selectExtensions.ts +68 -68
  42. package/src/slotBinding.ts +84 -84
  43. package/src/subscribable.ts +266 -266
  44. package/src/tasks.ts +79 -79
  45. package/src/templateEngine.ts +108 -108
  46. package/src/templateRendering.ts +399 -399
  47. package/src/templateRewriting.ts +94 -94
  48. package/src/templateSources.ts +134 -134
  49. package/src/utils.ts +123 -123
  50. package/src/utilsDom.ts +87 -87
  51. package/src/virtualElements.ts +153 -153
  52. package/src/wireParams.ts +69 -49
package/src/filters.ts CHANGED
@@ -1,91 +1,91 @@
1
- import { addBindingPreprocessor, setFiltersRegistry } from './bindingProvider.js';
2
- import type { PreprocessFn } from './bindingProvider.js';
3
- import { unwrapObservable, toJSON } from './utils.js';
4
-
5
- // ---- Filter Registry ----
6
-
7
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
8
- export const filters: Record<string, Function> = {};
9
-
10
- // Register the filters object so binding expressions can access it as $filters
11
- setFiltersRegistry(filters);
12
-
13
- // ---- Filter Preprocessor ----
14
-
15
- // Tokenizer regex: matches quoted strings, || (logical OR — not a pipe), single | and :
16
- // as individual tokens, and any non-whitespace runs between delimiters.
17
- const TOKEN_REGEX = /"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|\|\||[|:]|[^\s|:"'][^|:"']*[^\s|:"']|[^\s|:"']/g;
18
-
19
- // Transforms `expression | filter1 | filter2:arg1:arg2` into
20
- // `$filters['filter2']($filters['filter1'](expression),arg1,arg2)`
21
- export const filterPreprocessor: PreprocessFn = function (input: string): string | void {
22
- if (input.indexOf('|') === -1) return input;
23
-
24
- const tokens = input.match(TOKEN_REGEX);
25
- if (tokens && tokens.length > 1) {
26
- tokens.push('|');
27
- let result = tokens[0];
28
- let lastToken: string | undefined;
29
- let inFilters = false;
30
- let nextIsFilter = false;
31
-
32
- for (let i = 1; i < tokens.length; i++) {
33
- const token = tokens[i];
34
- if (token === '|') {
35
- if (inFilters) {
36
- if (lastToken === ':') result += 'undefined';
37
- result += ')';
38
- }
39
- nextIsFilter = true;
40
- inFilters = true;
41
- } else {
42
- if (nextIsFilter) {
43
- result = "$filters['" + token + "'](" + result;
44
- } else if (inFilters && token === ':') {
45
- if (lastToken === ':') result += 'undefined';
46
- result += ',';
47
- } else {
48
- result += token;
49
- }
50
- nextIsFilter = false;
51
- }
52
- lastToken = token;
53
- }
54
-
55
- return result;
56
- }
57
-
58
- return input;
59
- };
60
-
61
- // Enable the filter preprocessor for a specific binding handler
62
- export function enableTextFilter(bindingKeyOrHandler: string): void {
63
- addBindingPreprocessor(bindingKeyOrHandler, filterPreprocessor);
64
- }
65
-
66
- // ---- Built-in Filters ----
67
-
68
- filters['uppercase'] = function (value: unknown): string {
69
- return String(unwrapObservable(value) ?? '').toUpperCase();
70
- };
71
-
72
- filters['lowercase'] = function (value: unknown): string {
73
- return String(unwrapObservable(value) ?? '').toLowerCase();
74
- };
75
-
76
- filters['default'] = function (value: unknown, defaultValue: unknown): unknown {
77
- const unwrapped = unwrapObservable(value);
78
- if (typeof unwrapped === 'function') return unwrapped;
79
- if (typeof unwrapped === 'string') return unwrapped.trim() === '' ? defaultValue : unwrapped;
80
- if (unwrapped == null) return defaultValue;
81
- if (Array.isArray(unwrapped) && unwrapped.length === 0) return defaultValue;
82
- return unwrapped;
83
- };
84
-
85
- filters['json'] = function (
86
- rootObject: unknown,
87
- space?: string | number,
88
- replacer?: (key: string, value: unknown) => unknown,
89
- ): string {
90
- return toJSON(rootObject, replacer, space);
91
- };
1
+ import { addBindingPreprocessor, setFiltersRegistry } from './bindingProvider.js';
2
+ import type { PreprocessFn } from './bindingProvider.js';
3
+ import { unwrapObservable, toJSON } from './utils.js';
4
+
5
+ // ---- Filter Registry ----
6
+
7
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
8
+ export const filters: Record<string, Function> = {};
9
+
10
+ // Register the filters object so binding expressions can access it as $filters
11
+ setFiltersRegistry(filters);
12
+
13
+ // ---- Filter Preprocessor ----
14
+
15
+ // Tokenizer regex: matches quoted strings, || (logical OR — not a pipe), single | and :
16
+ // as individual tokens, and any non-whitespace runs between delimiters.
17
+ const TOKEN_REGEX = /"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|\|\||[|:]|[^\s|:"'][^|:"']*[^\s|:"']|[^\s|:"']/g;
18
+
19
+ // Transforms `expression | filter1 | filter2:arg1:arg2` into
20
+ // `$filters['filter2']($filters['filter1'](expression),arg1,arg2)`
21
+ export const filterPreprocessor: PreprocessFn = function (input: string): string | void {
22
+ if (input.indexOf('|') === -1) return input;
23
+
24
+ const tokens = input.match(TOKEN_REGEX);
25
+ if (tokens && tokens.length > 1) {
26
+ tokens.push('|');
27
+ let result = tokens[0];
28
+ let lastToken: string | undefined;
29
+ let inFilters = false;
30
+ let nextIsFilter = false;
31
+
32
+ for (let i = 1; i < tokens.length; i++) {
33
+ const token = tokens[i];
34
+ if (token === '|') {
35
+ if (inFilters) {
36
+ if (lastToken === ':') result += 'undefined';
37
+ result += ')';
38
+ }
39
+ nextIsFilter = true;
40
+ inFilters = true;
41
+ } else {
42
+ if (nextIsFilter) {
43
+ result = "$filters['" + token + "'](" + result;
44
+ } else if (inFilters && token === ':') {
45
+ if (lastToken === ':') result += 'undefined';
46
+ result += ',';
47
+ } else {
48
+ result += token;
49
+ }
50
+ nextIsFilter = false;
51
+ }
52
+ lastToken = token;
53
+ }
54
+
55
+ return result;
56
+ }
57
+
58
+ return input;
59
+ };
60
+
61
+ // Enable the filter preprocessor for a specific binding handler
62
+ export function enableTextFilter(bindingKeyOrHandler: string): void {
63
+ addBindingPreprocessor(bindingKeyOrHandler, filterPreprocessor);
64
+ }
65
+
66
+ // ---- Built-in Filters ----
67
+
68
+ filters['uppercase'] = function (value: unknown): string {
69
+ return String(unwrapObservable(value) ?? '').toUpperCase();
70
+ };
71
+
72
+ filters['lowercase'] = function (value: unknown): string {
73
+ return String(unwrapObservable(value) ?? '').toLowerCase();
74
+ };
75
+
76
+ filters['default'] = function (value: unknown, defaultValue: unknown): unknown {
77
+ const unwrapped = unwrapObservable(value);
78
+ if (typeof unwrapped === 'function') return unwrapped;
79
+ if (typeof unwrapped === 'string') return unwrapped.trim() === '' ? defaultValue : unwrapped;
80
+ if (unwrapped == null) return defaultValue;
81
+ if (Array.isArray(unwrapped) && unwrapped.length === 0) return defaultValue;
82
+ return unwrapped;
83
+ };
84
+
85
+ filters['json'] = function (
86
+ rootObject: unknown,
87
+ space?: string | number,
88
+ replacer?: (key: string, value: unknown) => unknown,
89
+ ): string {
90
+ return toJSON(rootObject, replacer, space);
91
+ };
package/src/index.ts CHANGED
@@ -1,150 +1,150 @@
1
- export * from './core.js';
2
-
3
- export { wireParams } from './wireParams.js';
4
- export type { WireParamsResult } from './wireParams.js';
5
-
6
- export {
7
- cloneNodes,
8
- fixUpContinuousNodeArray,
9
- replaceDomNodes,
10
- moveCleanedNodesToContainerElement,
11
- parseHtmlFragment,
12
- domNodeIsAttachedToDocument,
13
- anyDomNodeIsAttachedToDocument,
14
- } from './utilsDom.js';
15
-
16
- export { domDataGet, domDataSet, domDataGetOrSet, domDataClear, domDataNextKey } from './domData.js';
17
-
18
- export { addDisposeCallback, removeDisposeCallback, cleanNode, removeNode } from './domNodeDisposal.js';
19
-
20
- export {
21
- isStartComment,
22
- hasBindingValue,
23
- virtualNodeBindingValue,
24
- virtualChildNodes,
25
- virtualFirstChild,
26
- virtualNextSibling,
27
- virtualEmptyNode,
28
- virtualSetChildren,
29
- virtualPrepend,
30
- virtualInsertAfter,
31
- allowedVirtualElementBindings,
32
- } from './virtualElements.js';
33
-
34
- export {
35
- parseObjectLiteral,
36
- preProcessBindings,
37
- twoWayBindings,
38
- writeValueToProperty,
39
- keyValueArrayContainsKey,
40
- } from './expressionRewriting.js';
41
- export type { KeyValuePair, PreProcessOptions, AllBindingsAccessor } from './expressionRewriting.js';
42
-
43
- export {
44
- BindingContext,
45
- contextFor,
46
- dataFor,
47
- storedBindingContextForNode,
48
- SUBSCRIBABLE,
49
- ANCESTOR_BINDING_INFO,
50
- DATA_DEPENDENCY,
51
- BINDING_INFO_KEY,
52
- } from './bindingContext.js';
53
- export type { BindingContextOptions, CreateChildContextOptions, ExtendCallback } from './bindingContext.js';
54
-
55
- export {
56
- BindingProvider,
57
- bindingHandlers,
58
- getBindingHandler,
59
- addBindingPreprocessor,
60
- addNodePreprocessor,
61
- addBindingHandlerCreator,
62
- chainPreprocessor,
63
- instance as bindingProviderInstance,
64
- } from './bindingProvider.js';
65
- export type { BindingHandler, PreprocessFn, NodePreprocessFn } from './bindingProvider.js';
66
-
67
- export {
68
- applyBindings,
69
- applyBindingsToDescendants,
70
- applyBindingsToNode,
71
- applyBindingAccessorsToNode,
72
- } from './applyBindings.js';
73
-
74
- export { bindingEvent } from './bindingEvent.js';
75
- export type { BindingInfo } from './bindingEvent.js';
76
-
77
- import * as selectExtensions from './selectExtensions.js';
78
- export { selectExtensions };
79
-
80
- export { DomElementSource, AnonymousSource } from './templateSources.js';
81
-
82
- export {
83
- TemplateEngine,
84
- NativeTemplateEngine,
85
- nativeTemplateEngine,
86
- setTemplateEngine,
87
- getTemplateEngine,
88
- } from './templateEngine.js';
89
- export type { TemplateRenderOptions, TemplateSource } from './templateEngine.js';
90
-
91
- export { setDomNodeChildrenFromArrayMapping } from './arrayToDomMapping.js';
92
- export type { ArrayMappingOptions } from './arrayToDomMapping.js';
93
-
94
- export { renderTemplate, renderTemplateForEach } from './templateRendering.js';
95
-
96
- import * as memoization from './memoization.js';
97
- export { memoization };
98
-
99
- export {
100
- ensureTemplateIsRewritten,
101
- memoizeBindingAttributeSyntax,
102
- applyMemoizedBindingsToNextSibling,
103
- bindingRewriteValidators,
104
- } from './templateRewriting.js';
105
-
106
- import * as components from './components.js';
107
- export { components };
108
- export type { ComponentDefinition, ComponentConfig, ComponentLoader, ComponentInfo } from './components.js';
109
-
110
- export { getComponentNameForNode, addBindingsForCustomElement } from './componentBinding.js';
111
-
112
- export { component, getComponentTag } from './componentDecorator.js';
113
- export type { ComponentOptions } from './componentDecorator.js';
114
- export type { ViewModelFactory } from './options.js';
115
-
116
- export {
117
- parseInterpolationMarkup,
118
- wrapExpression,
119
- interpolationMarkupPreprocessor,
120
- enableInterpolationMarkup,
121
- } from './interpolationMarkup.js';
122
-
123
- export {
124
- attributeBinding,
125
- setAttributeBinding,
126
- attributeInterpolationMarkupPreprocessor,
127
- enableAttributeInterpolationMarkup,
128
- } from './attributeInterpolationMarkup.js';
129
-
130
- export {
131
- defaultGetNamespacedHandler,
132
- enableNamespacedBindings,
133
- autoNamespacedPreprocessor,
134
- enableAutoNamespacedSyntax,
135
- addDefaultNamespacedBindingPreprocessor,
136
- } from './namespacedBindings.js';
137
-
138
- export {
139
- filters,
140
- filterPreprocessor,
141
- enableTextFilter,
142
- } from './filters.js';
143
-
144
- export { enableAll, resetConfigured } from './configure.js';
145
-
146
- import './bindings.js';
147
- import './templateRendering.js';
148
- import './controlFlowBindings.js';
149
- import './componentBinding.js';
150
- import './slotBinding.js';
1
+ export * from './core.js';
2
+
3
+ export { wireParams } from './wireParams.js';
4
+ export type { WireParamsResult } from './wireParams.js';
5
+
6
+ export {
7
+ cloneNodes,
8
+ fixUpContinuousNodeArray,
9
+ replaceDomNodes,
10
+ moveCleanedNodesToContainerElement,
11
+ parseHtmlFragment,
12
+ domNodeIsAttachedToDocument,
13
+ anyDomNodeIsAttachedToDocument,
14
+ } from './utilsDom.js';
15
+
16
+ export { domDataGet, domDataSet, domDataGetOrSet, domDataClear, domDataNextKey } from './domData.js';
17
+
18
+ export { addDisposeCallback, removeDisposeCallback, cleanNode, removeNode } from './domNodeDisposal.js';
19
+
20
+ export {
21
+ isStartComment,
22
+ hasBindingValue,
23
+ virtualNodeBindingValue,
24
+ virtualChildNodes,
25
+ virtualFirstChild,
26
+ virtualNextSibling,
27
+ virtualEmptyNode,
28
+ virtualSetChildren,
29
+ virtualPrepend,
30
+ virtualInsertAfter,
31
+ allowedVirtualElementBindings,
32
+ } from './virtualElements.js';
33
+
34
+ export {
35
+ parseObjectLiteral,
36
+ preProcessBindings,
37
+ twoWayBindings,
38
+ writeValueToProperty,
39
+ keyValueArrayContainsKey,
40
+ } from './expressionRewriting.js';
41
+ export type { KeyValuePair, PreProcessOptions, AllBindingsAccessor } from './expressionRewriting.js';
42
+
43
+ export {
44
+ BindingContext,
45
+ contextFor,
46
+ dataFor,
47
+ storedBindingContextForNode,
48
+ SUBSCRIBABLE,
49
+ ANCESTOR_BINDING_INFO,
50
+ DATA_DEPENDENCY,
51
+ BINDING_INFO_KEY,
52
+ } from './bindingContext.js';
53
+ export type { BindingContextOptions, CreateChildContextOptions, ExtendCallback } from './bindingContext.js';
54
+
55
+ export {
56
+ BindingProvider,
57
+ bindingHandlers,
58
+ getBindingHandler,
59
+ addBindingPreprocessor,
60
+ addNodePreprocessor,
61
+ addBindingHandlerCreator,
62
+ chainPreprocessor,
63
+ instance as bindingProviderInstance,
64
+ } from './bindingProvider.js';
65
+ export type { BindingHandler, PreprocessFn, NodePreprocessFn } from './bindingProvider.js';
66
+
67
+ export {
68
+ applyBindings,
69
+ applyBindingsToDescendants,
70
+ applyBindingsToNode,
71
+ applyBindingAccessorsToNode,
72
+ } from './applyBindings.js';
73
+
74
+ export { bindingEvent } from './bindingEvent.js';
75
+ export type { BindingInfo } from './bindingEvent.js';
76
+
77
+ import * as selectExtensions from './selectExtensions.js';
78
+ export { selectExtensions };
79
+
80
+ export { DomElementSource, AnonymousSource } from './templateSources.js';
81
+
82
+ export {
83
+ TemplateEngine,
84
+ NativeTemplateEngine,
85
+ nativeTemplateEngine,
86
+ setTemplateEngine,
87
+ getTemplateEngine,
88
+ } from './templateEngine.js';
89
+ export type { TemplateRenderOptions, TemplateSource } from './templateEngine.js';
90
+
91
+ export { setDomNodeChildrenFromArrayMapping } from './arrayToDomMapping.js';
92
+ export type { ArrayMappingOptions } from './arrayToDomMapping.js';
93
+
94
+ export { renderTemplate, renderTemplateForEach } from './templateRendering.js';
95
+
96
+ import * as memoization from './memoization.js';
97
+ export { memoization };
98
+
99
+ export {
100
+ ensureTemplateIsRewritten,
101
+ memoizeBindingAttributeSyntax,
102
+ applyMemoizedBindingsToNextSibling,
103
+ bindingRewriteValidators,
104
+ } from './templateRewriting.js';
105
+
106
+ import * as components from './components.js';
107
+ export { components };
108
+ export type { ComponentDefinition, ComponentConfig, ComponentLoader, ComponentInfo } from './components.js';
109
+
110
+ export { getComponentNameForNode, addBindingsForCustomElement } from './componentBinding.js';
111
+
112
+ export { component, getComponentTag } from './componentDecorator.js';
113
+ export type { ComponentOptions } from './componentDecorator.js';
114
+ export type { ViewModelFactory } from './options.js';
115
+
116
+ export {
117
+ parseInterpolationMarkup,
118
+ wrapExpression,
119
+ interpolationMarkupPreprocessor,
120
+ enableInterpolationMarkup,
121
+ } from './interpolationMarkup.js';
122
+
123
+ export {
124
+ attributeBinding,
125
+ setAttributeBinding,
126
+ attributeInterpolationMarkupPreprocessor,
127
+ enableAttributeInterpolationMarkup,
128
+ } from './attributeInterpolationMarkup.js';
129
+
130
+ export {
131
+ defaultGetNamespacedHandler,
132
+ enableNamespacedBindings,
133
+ autoNamespacedPreprocessor,
134
+ enableAutoNamespacedSyntax,
135
+ addDefaultNamespacedBindingPreprocessor,
136
+ } from './namespacedBindings.js';
137
+
138
+ export {
139
+ filters,
140
+ filterPreprocessor,
141
+ enableTextFilter,
142
+ } from './filters.js';
143
+
144
+ export { enableAll, resetConfigured } from './configure.js';
145
+
146
+ import './bindings.js';
147
+ import './templateRendering.js';
148
+ import './controlFlowBindings.js';
149
+ import './componentBinding.js';
150
+ import './slotBinding.js';