@ng-atomic/core 16.2.0 → 17.0.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,56 @@
1
+ import { DestroyRef, Directive, ElementRef, inject } from "@angular/core";
2
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
3
+ import { InjectableComponent } from "./injectable-component";
4
+ import { EffectMap, injectEffectEntries, injectEffectReducer } from "./effect";
5
+ import { NgAtomicRootActionStore } from "./action-store";
6
+ import { DebugDirective } from './debug';
7
+ import * as i0 from "@angular/core";
8
+ import * as i1 from "./debug/debug.directive";
9
+ export class NgAtomicComponent extends InjectableComponent {
10
+ effectEntries = injectEffectEntries();
11
+ reducer = injectEffectReducer();
12
+ _effectMap;
13
+ root = inject(NgAtomicRootActionStore);
14
+ #destroyRef = inject(DestroyRef);
15
+ #el = inject(ElementRef);
16
+ constructor() {
17
+ super();
18
+ this.root.actions$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(action => {
19
+ this.#effect(action, 'root');
20
+ });
21
+ }
22
+ async dispatch(action, scope = 'default', componentId = null) {
23
+ const selector = this.#el.nativeElement.tagName.toLowerCase();
24
+ const _action = { ...action, meta: { componentId, selector } };
25
+ const props = await this.reducer(_action);
26
+ if (props?.dispatch === false)
27
+ return;
28
+ const effect = this.#effect(_action, scope);
29
+ this.root.log(_action, scope);
30
+ if (scope === 'root' && (!effect?.props || effect?.props?.dispatch)) {
31
+ this.root.actions$.emit(_action);
32
+ }
33
+ else if (!effect?.props || effect?.props?.dispatch) {
34
+ super.dispatch(_action);
35
+ }
36
+ }
37
+ #effect(action, scope = 'default') {
38
+ const effect = (this._effectMap ?? new EffectMap()).get(action.id, scope);
39
+ if (effect?.key && effect?.props?.scope === scope) {
40
+ this[effect.key](effect.props.accessor(action));
41
+ }
42
+ return effect;
43
+ }
44
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: NgAtomicComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
45
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.2", type: NgAtomicComponent, isStandalone: true, usesInheritance: true, hostDirectives: [{ directive: i1.DebugDirective }], ngImport: i0 });
46
+ }
47
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: NgAtomicComponent, decorators: [{
48
+ type: Directive,
49
+ args: [{
50
+ standalone: true,
51
+ hostDirectives: [
52
+ DebugDirective,
53
+ ],
54
+ }]
55
+ }], ctorParameters: () => [] });
56
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmctYXRvbWljLWNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL0BuZy1hdG9taWMvY29yZS9zcmMvbGliL25nLWF0b21pYy1jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxTQUFTLEVBQUUsVUFBVSxFQUFFLE1BQU0sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUMxRSxPQUFPLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUVoRSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM3RCxPQUFPLEVBQUUsU0FBUyxFQUFFLG1CQUFtQixFQUFFLG1CQUFtQixFQUFFLE1BQU0sVUFBVSxDQUFDO0FBQy9FLE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQ3pELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxTQUFTLENBQUM7OztBQVF6QyxNQUFNLE9BQU8saUJBQTJCLFNBQVEsbUJBQXNCO0lBQzFELGF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ICAgIHRoaXMucm9vdC5hY3Rpb25zJC5lbWl0KF9hY3Rpb24pO1xuICAgIH0gZWxzZSBpZiAoIWVmZmVjdD8ucHJvcHMgfHwgZWZmZWN0Py5wcm9wcz8uZGlzcGF0Y2gpIHtcbiAgICAgIHN1cGVyLmRpc3BhdGNoKF9hY3Rpb24pO1xuICAgIH1cbiAgfVxuXG4gICNlZmZlY3QoYWN0aW9uOiBBY3Rpb24sIHNjb3BlID0gJ2RlZmF1bHQnKSB7XG4gICAgY29uc3QgZWZmZWN0ID0gKHRoaXMuX2VmZmVjdE1hcCA/PyBuZXcgRWZmZWN0TWFwKCkpLmdldChhY3Rpb24uaWQsIHNjb3BlKTtcbiAgICBpZiAoZWZmZWN0Py5rZXkgJiYgZWZmZWN0Py5wcm9wcz8uc2NvcGUgPT09IHNjb3BlKSB7XG4gICAgICB0aGlzW2VmZmVjdC5rZXldKGVmZmVjdC5wcm9wcy5hY2Nlc3NvcihhY3Rpb24pKTtcbiAgICB9XG4gICAgcmV0dXJuIGVmZmVjdDtcbiAgfVxufVxuIl19
@@ -0,0 +1,6 @@
1
+ import { InjectionToken } from "@angular/core";
2
+ export const NG_ATOMIC_DEBUG = new InjectionToken('NG_ATOMIC_DEBUG');
3
+ export function withNgAtomicDebug() {
4
+ return { provide: NG_ATOMIC_DEBUG, useValue: true };
5
+ }
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmctYXRvbWljLWRlYnVnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvQG5nLWF0b21pYy9jb3JlL3NyYy9saWIvbmctYXRvbWljLWRlYnVnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFL0MsTUFBTSxDQUFDLE1BQU0sZUFBZSxHQUFHLElBQUksY0FBYyxDQUFVLGlCQUFpQixDQUFDLENBQUM7QUFDOUUsTUFBTSxVQUFVLGlCQUFpQjtJQUMvQixPQUFPLEVBQUMsT0FBTyxFQUFFLGVBQWUsRUFBRSxRQUFRLEVBQUUsSUFBSSxFQUFDLENBQUM7QUFDcEQsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IEluamVjdGlvblRva2VuIH0gZnJvbSBcIkBhbmd1bGFyL2NvcmVcIjtcblxuZXhwb3J0IGNvbnN0IE5HX0FUT01JQ19ERUJVRyA9IG5ldyBJbmplY3Rpb25Ub2tlbjxib29sZWFuPignTkdfQVRPTUlDX0RFQlVHJyk7XG5leHBvcnQgZnVuY3Rpb24gd2l0aE5nQXRvbWljRGVidWcoKSB7XG4gIHJldHVybiB7cHJvdmlkZTogTkdfQVRPTUlDX0RFQlVHLCB1c2VWYWx1ZTogdHJ1ZX07XG59XG4iXX0=
@@ -0,0 +1,60 @@
1
+ import { Pipe, computed, isSignal } from "@angular/core";
2
+ import * as i0 from "@angular/core";
3
+ function call(valueOrSignal) {
4
+ return isSignal(valueOrSignal) ? call(valueOrSignal()) : valueOrSignal;
5
+ }
6
+ export function proxyFakeComputedInputValueFn(inputValueFn) {
7
+ return new Proxy(inputValueFn, {
8
+ apply: function (target, _, args) {
9
+ return computeFake(target(...args));
10
+ }
11
+ });
12
+ }
13
+ export function computeFake(valueOrFakeComputed) {
14
+ return isFakeComputed(valueOrFakeComputed) ? valueOrFakeComputed() : valueOrFakeComputed;
15
+ }
16
+ export function proxyFakeComputedInputs(target, inputs) {
17
+ inputs.filter(input => isSignal(target[input])).forEach(input => {
18
+ target[input] = proxyFakeComputedInputValueFn(target[input]);
19
+ });
20
+ }
21
+ export const FAKE_COMPUTED = /* @__PURE__ */ Symbol('FAKE_COMPUTED');
22
+ export function compute(target, propName) {
23
+ let inputValueFn;
24
+ Object.defineProperty(target, propName, {
25
+ get() {
26
+ return new Proxy(inputValueFn, {
27
+ apply: function (target, _, args) {
28
+ const valueOrSignal = target(...args);
29
+ return isSignal(valueOrSignal) ? valueOrSignal() : valueOrSignal;
30
+ }
31
+ });
32
+ },
33
+ set(value) {
34
+ inputValueFn = value;
35
+ },
36
+ });
37
+ }
38
+ export function fakeComputed(computation, options) {
39
+ const _computed = computed(computation, options);
40
+ _computed[FAKE_COMPUTED] = true;
41
+ return _computed;
42
+ }
43
+ export function _computed(computation, options) {
44
+ return fakeComputed(computation, options);
45
+ }
46
+ export function isFakeComputed(_computed) {
47
+ return !!_computed?.[FAKE_COMPUTED];
48
+ }
49
+ export class CallPipe {
50
+ transform(value) {
51
+ return call(value);
52
+ }
53
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: CallPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
54
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.2.2", ngImport: i0, type: CallPipe, isStandalone: true, name: "call" });
55
+ }
56
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: CallPipe, decorators: [{
57
+ type: Pipe,
58
+ args: [{ name: 'call', standalone: true, pure: true }]
59
+ }] });
60
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbmFscy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL0BuZy1hdG9taWMvY29yZS9zcmMvbGliL3NpZ25hbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUF5QixJQUFJLEVBQVUsUUFBUSxFQUFFLFFBQVEsRUFBaUIsTUFBTSxlQUFlLENBQUM7O0FBRXZHLFNBQVMsSUFBSSxDQUFJLGFBQTRCO0lBQzNDLE9BQU8sUUFBUSxDQUFDLGFBQWEsQ0FBQyxDQUFDLENBQUMsQ0FBQyx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dGF0aW9uOiAoKSA9PiBULCBvcHRpb25zPzogQ3JlYXRlQ29tcHV0ZWRPcHRpb25zPFQ+KTogVCB7XG4gIGNvbnN0IF9jb21wdXRlZCA9IGNvbXB1dGVkKGNvbXB1dGF0aW9uLCBvcHRpb25zKSBhcyBuZXZlciBhcyBUO1xuICBfY29tcHV0ZWRbRkFLRV9DT01QVVRFRF0gPSB0cnVlO1xuICByZXR1cm4gX2NvbXB1dGVkO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gX2NvbXB1dGVkPFQ+KGNvbXB1dGF0aW9uOiAoKSA9PiBULCBvcHRpb25zPzogQ3JlYXRlQ29tcHV0ZWRPcHRpb25zPFQ+KTogVCB7XG4gIHJldHVybiBmYWtlQ29tcHV0ZWQoY29tcHV0YXRpb24sIG9wdGlvbnMpO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gaXNGYWtlQ29tcHV0ZWQoX2NvbXB1dGVkOiBhbnkpOiBfY29tcHV0ZWQgaXMgUmV0dXJuVHlwZTx0eXBlb2YgY29tcHV0ZWQ+IHtcbiAgcmV0dXJuICEhX2NvbXB1dGVkPy5bRkFLRV9DT01QVVRFRF07XG59XG5cbkBQaXBlKHsgbmFtZTogJ2NhbGwnLCBzdGFuZGFsb25lOiB0cnVlLCBwdXJlOiB0cnVlfSlcbmV4cG9ydCBjbGFzcyBDYWxsUGlwZSBpbXBsZW1lbnRzIFBpcGVUcmFuc2Zvcm0ge1xuICB0cmFuc2Zvcm08VD4odmFsdWU6IFNpZ25hbDxUPiB8IFQpOiBUIHtcbiAgICByZXR1cm4gY2FsbCh2YWx1ZSk7XG4gIH1cbn1cbiJdfQ==
@@ -1,10 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Injectable, inject, ViewContainerRef, Injector, DestroyRef, ElementRef, reflectComponentType, Directive, Input, Output } from '@angular/core';
2
+ import { EventEmitter, Injectable, InjectionToken, runInInjectionContext, Injector, inject, isSignal, computed, Pipe, PLATFORM_ID, ViewContainerRef, DestroyRef, ElementRef, input, ɵoutput as _output, reflectComponentType, Directive } from '@angular/core';
3
3
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
+ import { isPlatformBrowser } from '@angular/common';
4
5
 
5
6
  class NgAtomicRootActionStore {
7
+ actions$ = new EventEmitter();
6
8
  constructor() {
7
- this.actions$ = new EventEmitter();
8
9
  this.actions$.subscribe(action => this.log(action, 'root'));
9
10
  }
10
11
  dispatch(action) {
@@ -13,13 +14,13 @@ class NgAtomicRootActionStore {
13
14
  log(action, scope = 'default') {
14
15
  console.debug(action, scope);
15
16
  }
16
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgAtomicRootActionStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
17
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgAtomicRootActionStore, providedIn: 'root' }); }
17
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: NgAtomicRootActionStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
18
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: NgAtomicRootActionStore, providedIn: 'root' });
18
19
  }
19
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgAtomicRootActionStore, decorators: [{
20
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: NgAtomicRootActionStore, decorators: [{
20
21
  type: Injectable,
21
22
  args: [{ providedIn: 'root' }]
22
- }], ctorParameters: function () { return []; } });
23
+ }], ctorParameters: () => [] });
23
24
 
24
25
  function resolveActions(actions, ...args) {
25
26
  if (typeof actions === 'function') {
@@ -27,6 +28,9 @@ function resolveActions(actions, ...args) {
27
28
  }
28
29
  return actions;
29
30
  }
31
+ function wrapActions(actions) {
32
+ return typeof actions === 'function' ? actions : () => actions;
33
+ }
30
34
 
31
35
  class EffectMap extends Map {
32
36
  get(key, scope = 'default') {
@@ -48,7 +52,129 @@ function Effect(id, { dispatch = false, scope = 'default', accessor = (action) =
48
52
  target['_effectMap'].set(id, { key: propertyKey, props: { dispatch, scope, accessor } });
49
53
  };
50
54
  }
55
+ const EFFECT_ENTRY = new InjectionToken('EFFECT_ENTRY');
56
+ function provideEffect(ActionIds, _effectFactory, options = { dispatch: false }) {
57
+ return {
58
+ provide: EFFECT_ENTRY,
59
+ useFactory: (injector) => {
60
+ const effectFactory = (hostInjector) => {
61
+ return runInInjectionContext(hostInjector, () => _effectFactory(injector));
62
+ };
63
+ return { actionIds: ActionIds, effectFactory, options };
64
+ },
65
+ multi: true,
66
+ deps: [Injector]
67
+ };
68
+ }
69
+ function injectEffectEntries() {
70
+ return inject(EFFECT_ENTRY, { optional: true }) ?? [];
71
+ }
72
+ function buildEffectEntryMap(injector, effectEntries) {
73
+ const effectEntryMap = new Map();
74
+ for (const entry of effectEntries) {
75
+ const ids = Array.isArray(entry.actionIds) ? entry.actionIds : [entry.actionIds];
76
+ for (const id of ids) {
77
+ const effect = () => entry.effectFactory(injector);
78
+ effectEntryMap.set(id, { effect, options: entry.options });
79
+ }
80
+ }
81
+ return effectEntryMap;
82
+ }
83
+ class EffectReducer {
84
+ injector = inject(Injector);
85
+ effectEntries = injectEffectEntries();
86
+ effectEntryMap = buildEffectEntryMap(this.injector, this.effectEntries);
87
+ async reduce(action) {
88
+ const entry = this.effectEntryMap.get(action.id);
89
+ if (entry) {
90
+ await runInInjectionContext(this.injector, () => {
91
+ return entry?.effect()(action.payload, { injector: this.injector });
92
+ });
93
+ return this.effectEntryMap.get(action.id)?.options ?? { dispatch: false };
94
+ }
95
+ return { dispatch: true };
96
+ }
97
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: EffectReducer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
98
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: EffectReducer });
99
+ }
100
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: EffectReducer, decorators: [{
101
+ type: Injectable
102
+ }] });
103
+ function injectEffectReducer() {
104
+ const injector = inject(Injector);
105
+ const effectEntries = injectEffectEntries();
106
+ const effectEntryMap = buildEffectEntryMap(injector, effectEntries);
107
+ return async (action) => {
108
+ const entry = effectEntryMap.get(action.id);
109
+ if (entry) {
110
+ await runInInjectionContext(injector, () => {
111
+ return entry?.effect()(action.payload, { injector: injector });
112
+ });
113
+ return effectEntryMap.get(action.id)?.options ?? { dispatch: false };
114
+ }
115
+ return { dispatch: true };
116
+ };
117
+ }
118
+
119
+ function call(valueOrSignal) {
120
+ return isSignal(valueOrSignal) ? call(valueOrSignal()) : valueOrSignal;
121
+ }
122
+ function proxyFakeComputedInputValueFn(inputValueFn) {
123
+ return new Proxy(inputValueFn, {
124
+ apply: function (target, _, args) {
125
+ return computeFake(target(...args));
126
+ }
127
+ });
128
+ }
129
+ function computeFake(valueOrFakeComputed) {
130
+ return isFakeComputed(valueOrFakeComputed) ? valueOrFakeComputed() : valueOrFakeComputed;
131
+ }
132
+ function proxyFakeComputedInputs(target, inputs) {
133
+ inputs.filter(input => isSignal(target[input])).forEach(input => {
134
+ target[input] = proxyFakeComputedInputValueFn(target[input]);
135
+ });
136
+ }
137
+ const FAKE_COMPUTED = /* @__PURE__ */ Symbol('FAKE_COMPUTED');
138
+ function compute(target, propName) {
139
+ let inputValueFn;
140
+ Object.defineProperty(target, propName, {
141
+ get() {
142
+ return new Proxy(inputValueFn, {
143
+ apply: function (target, _, args) {
144
+ const valueOrSignal = target(...args);
145
+ return isSignal(valueOrSignal) ? valueOrSignal() : valueOrSignal;
146
+ }
147
+ });
148
+ },
149
+ set(value) {
150
+ inputValueFn = value;
151
+ },
152
+ });
153
+ }
154
+ function fakeComputed(computation, options) {
155
+ const _computed = computed(computation, options);
156
+ _computed[FAKE_COMPUTED] = true;
157
+ return _computed;
158
+ }
159
+ function _computed(computation, options) {
160
+ return fakeComputed(computation, options);
161
+ }
162
+ function isFakeComputed(_computed) {
163
+ return !!_computed?.[FAKE_COMPUTED];
164
+ }
165
+ class CallPipe {
166
+ transform(value) {
167
+ return call(value);
168
+ }
169
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: CallPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
170
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.2.2", ngImport: i0, type: CallPipe, isStandalone: true, name: "call" });
171
+ }
172
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: CallPipe, decorators: [{
173
+ type: Pipe,
174
+ args: [{ name: 'call', standalone: true, pure: true }]
175
+ }] });
51
176
 
177
+ const TOKEN = 'Δtkn';
52
178
  function provideComponent(abstract, typeOrFactory) {
53
179
  async function loadComponentType() {
54
180
  if (typeof typeOrFactory === 'function' && !typeOrFactory.prototype) {
@@ -59,7 +185,15 @@ function provideComponent(abstract, typeOrFactory) {
59
185
  }
60
186
  }
61
187
  ;
62
- return { provide: abstract['TOKEN'], useValue: loadComponentType };
188
+ return { provide: abstract[TOKEN], useValue: loadComponentType };
189
+ }
190
+ function TokenizedType() {
191
+ return function (type) {
192
+ type[TOKEN] = new InjectionToken(type.name);
193
+ };
194
+ }
195
+ function getToken(type) {
196
+ return type[TOKEN];
63
197
  }
64
198
  var HostType;
65
199
  (function (HostType) {
@@ -71,11 +205,12 @@ function getMeta(type) {
71
205
  }
72
206
  function getInputs(type) {
73
207
  return Object.entries(getMeta(type)['inputs'])
74
- .map(([propName, templateName]) => ({ propName, templateName }));
208
+ .map(([templateName, [propName]]) => ({ propName, templateName }));
75
209
  }
76
210
  function getOutputs(type) {
77
- return Object.entries(getMeta(type)['outputs'])
78
- .map(([propName, templateName]) => ({ propName, templateName }));
211
+ const meta = getMeta(type);
212
+ return Object.entries(meta['outputs'])
213
+ .map(([templateName, propName]) => ({ propName, templateName }));
79
214
  }
80
215
  function getInputsByComponentRef(cmp) {
81
216
  return getInputs(cmp.instance.constructor);
@@ -84,77 +219,94 @@ function getOutputsByInstance(cmp) {
84
219
  return getOutputs(cmp.instance.constructor);
85
220
  }
86
221
  class InjectableComponent {
87
- constructor() {
88
- this.#outlet = inject(ViewContainerRef);
89
- this.#injector = inject(Injector);
90
- this.#destroy$ = inject(DestroyRef);
91
- this.#el = inject(ElementRef);
92
- this.#component = null;
93
- this.#componentMirror = null;
94
- this.injectable = false;
95
- this.action = new EventEmitter();
96
- }
97
- #outlet;
98
- #injector;
99
- #destroy$;
100
- #el;
101
- #component;
102
- #componentMirror;
222
+ #platformId = inject(PLATFORM_ID);
223
+ #viewContainerRef = inject(ViewContainerRef);
224
+ #injector = inject(Injector);
225
+ #destroyRef = inject(DestroyRef);
226
+ #el = inject(ElementRef);
227
+ #component = null;
228
+ #componentMirror = null;
229
+ injectable = input(false, { transform: (value) => value === '' ? true : value, alias: 'injectable' });
230
+ __action = _output({ alias: 'action' });
231
+ dispatch(action) {
232
+ this.__action.emit(action);
233
+ }
234
+ get #inputs() {
235
+ const abs = getInputs(this.constructor);
236
+ return abs;
237
+ }
238
+ get #outputs() {
239
+ const abs = getOutputs(this.constructor);
240
+ return abs;
241
+ // const impl = this.#componentMirror!.outputs;
242
+ // return abs.filter(abstractOutput => impl.some(implOutput => implOutput.templateName === abstractOutput.templateName));
243
+ }
103
244
  #setAttribute() {
104
245
  const hostElement = this.#component.hostView.rootNodes[0];
105
246
  const attributes = this.#el.nativeElement.attributes;
106
247
  for (let i = 0; i < attributes.length; i++) {
107
248
  const attr = attributes.item(i);
108
- if (attr.name.startsWith('_ngcontent')) {
249
+ if (attr.name === 'injectable') {
250
+ hostElement.setAttribute('injected', '');
251
+ }
252
+ else {
109
253
  hostElement.setAttribute(attr.name, attr.value);
110
254
  }
111
255
  }
112
256
  }
113
257
  #bindInputs() {
114
- // for (const input of this.#componentMirror!.inputs) {
115
- // if (input.propName === 'injectable') return;
116
- // this.#component!.setInput(input.propName, (this as any)[input.propName]);
117
- // }
118
- for (const input of getInputs(this.constructor)) {
258
+ for (const input of this.#inputs) {
119
259
  if (input.propName === 'injectable')
120
- return;
121
- this.#component.setInput(input.propName, this[input.propName]);
260
+ continue;
261
+ const valueOrInputValueFn = this[input.propName];
262
+ const value = typeof valueOrInputValueFn === 'function' ? valueOrInputValueFn() : valueOrInputValueFn;
263
+ this.#component.setInput(input.templateName, value);
122
264
  }
123
265
  }
266
+ get propNames() {
267
+ return this.#inputs.map(input => input.propName);
268
+ }
269
+ proxyFakeComputedInputs() {
270
+ proxyFakeComputedInputs(this, this.propNames);
271
+ }
124
272
  #bindOutputs() {
125
- // for (const output of this.#componentMirror!.outputs) {
126
- // (this.#component!.instance as any)[output.templateName].pipe(
127
- // takeUntilDestroyed(this.#destroy$)
128
- // ).subscribe((value: any) => (this as any)[output.templateName].emit(value));
129
- // }
130
- for (const output of getOutputs(this.constructor)) {
131
- this.#component.instance[output.templateName]?.pipe(takeUntilDestroyed(this.#destroy$)).subscribe((value) => {
132
- console.debug('output=>>', output.templateName, value);
133
- this[output.templateName].emit(value);
273
+ for (const output of this.#outputs) {
274
+ this.#component.instance[output.propName]?.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((value) => this[output.propName].emit(value));
275
+ }
276
+ }
277
+ #bindEvents() {
278
+ for (const name of ['click']) {
279
+ this.#component.injector.get(ElementRef).nativeElement.addEventListener(name, (event) => {
280
+ this.#el.nativeElement.dispatchEvent(new Event(name, {}));
134
281
  });
135
282
  }
136
283
  }
284
+ constructor() {
285
+ this.proxyFakeComputedInputs();
286
+ }
137
287
  ngOnInit() {
138
- if (this.injectable) {
139
- this.#injector.get(this.constructor['TOKEN'])().then(type => {
140
- this.#component = this.#outlet.createComponent(type);
288
+ if (this.injectable() && isPlatformBrowser(this.#platformId)) {
289
+ this.#injector.get(getToken(this.constructor))().then(type => {
290
+ this.#component = this.#viewContainerRef.createComponent(type, {
291
+ projectableNodes: [
292
+ Array.from(this.#el.nativeElement.childNodes)
293
+ ],
294
+ });
141
295
  this.#componentMirror = reflectComponentType(type);
142
296
  this.#bindInputs();
143
297
  this.#bindOutputs();
298
+ this.#bindEvents();
144
299
  this.#setAttribute();
300
+ // this.#viewContainerRef.remove(0);
301
+ this.#component.changeDetectorRef.detectChanges();
302
+ // this.#el.nativeElement.remove();
145
303
  });
146
304
  }
305
+ this.proxyFakeComputedInputs();
147
306
  }
148
307
  ngOnChanges(simpleChanges) {
149
- if (this.injectable && this.#componentMirror) {
150
- // for (const input of this.#componentMirror.inputs) {
151
- // if (input.propName === 'injectable') return;
152
- // const change = simpleChanges[input.propName] as SimpleChange;
153
- // if (change) {
154
- // this.#component!.setInput(input.propName, change.currentValue);
155
- // }
156
- // }
157
- for (const input of getInputs(this.constructor)) {
308
+ if (this.injectable() && this.#componentMirror) {
309
+ for (const input of this.#inputs) {
158
310
  if (input.propName === 'injectable')
159
311
  return;
160
312
  const change = simpleChanges[input.propName];
@@ -164,66 +316,131 @@ class InjectableComponent {
164
316
  }
165
317
  }
166
318
  }
167
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: InjectableComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
168
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "16.2.12", type: InjectableComponent, isStandalone: true, inputs: { injectable: ["injectable", "injectable", (value) => value === '' ? true : value] }, outputs: { action: "action" }, usesOnChanges: true, ngImport: i0 }); }
319
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: InjectableComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
320
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "17.2.2", type: InjectableComponent, isStandalone: true, inputs: { injectable: { classPropertyName: "injectable", publicName: "injectable", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { __action: "action" }, usesOnChanges: true, ngImport: i0 });
169
321
  }
170
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: InjectableComponent, decorators: [{
322
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: InjectableComponent, decorators: [{
171
323
  type: Directive,
172
- args: [{ standalone: true }]
173
- }], propDecorators: { injectable: [{
174
- type: Input,
175
- args: [{ transform: (value) => value === '' ? true : value }]
176
- }], action: [{
177
- type: Output
178
- }] } });
324
+ args: [{
325
+ standalone: true,
326
+ // host: {ngSkipHydration: 'true'}
327
+ }]
328
+ }], ctorParameters: () => [] });
179
329
 
180
- class NgAtomicComponentStore {
181
- constructor() {
182
- this.action = new EventEmitter();
330
+ const NG_ATOMIC_DEBUG = new InjectionToken('NG_ATOMIC_DEBUG');
331
+ function withNgAtomicDebug() {
332
+ return { provide: NG_ATOMIC_DEBUG, useValue: true };
333
+ }
334
+
335
+ const DEBUG_CONFIG = {
336
+ outline: '1px',
337
+ colors: {
338
+ 'templates': '#f00',
339
+ 'organisms': '#0f0',
340
+ 'molecules': '#00f',
341
+ 'atoms': '#ff0',
342
+ 'frames': 'transparent',
343
+ 'default': '#000',
344
+ },
345
+ excludes: ['frames', 'app', 'pages', 'atoms'],
346
+ };
347
+ class DebugDirective {
348
+ el = inject(ElementRef);
349
+ platformId = inject(PLATFORM_ID);
350
+ isDebug = inject(NG_ATOMIC_DEBUG, { optional: true }) ?? false;
351
+ ngOnInit() {
352
+ if (isPlatformBrowser(this.platformId) && this.isDebug) {
353
+ const name = this.el.nativeElement.tagName.toLowerCase();
354
+ const type = name.split('-')[0];
355
+ if (DEBUG_CONFIG.excludes.includes(type))
356
+ return;
357
+ const color = DEBUG_CONFIG.colors?.[type] ?? DEBUG_CONFIG.colors.default;
358
+ // 1pxのアウトラインを設定
359
+ this.el.nativeElement.style.outline = `${DEBUG_CONFIG.outline} solid ${color}`;
360
+ // 疑似要素でコンポーネント名を表示
361
+ const labelEl = this.createLabelElement({
362
+ name: `${name}${this.el.nativeElement.hasAttribute('injected') ? '[injected]' : ''}`,
363
+ color
364
+ });
365
+ this.el.nativeElement.style.outlineOffset = '-1px';
366
+ this.el.nativeElement.style.position = 'relative';
367
+ this.el.nativeElement.appendChild(labelEl);
368
+ }
369
+ }
370
+ createLabelElement(options) {
371
+ const content = document.createElement('span');
372
+ content.textContent = options.name;
373
+ content.style.backgroundColor = `${options.color}`;
374
+ content.style.color = '#fff';
375
+ content.style.padding = '2px 4px';
376
+ content.style.position = 'absolute';
377
+ content.style.fontSize = '10px';
378
+ content.style.top = '0';
379
+ content.style.left = '0';
380
+ content.style.zIndex = '9999';
381
+ content.style.lineHeight = '1.5em';
382
+ content.style.whiteSpace = 'nowrap';
383
+ return content;
183
384
  }
184
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgAtomicComponentStore, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
185
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: NgAtomicComponentStore, isStandalone: true, ngImport: i0 }); }
385
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: DebugDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
386
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.2", type: DebugDirective, isStandalone: true, selector: "debug", ngImport: i0 });
186
387
  }
187
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgAtomicComponentStore, decorators: [{
388
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: DebugDirective, decorators: [{
188
389
  type: Directive,
189
- args: [{ standalone: true }]
390
+ args: [{ standalone: true, selector: 'debug' }]
190
391
  }] });
392
+
191
393
  class NgAtomicComponent extends InjectableComponent {
192
- #destroy$;
394
+ effectEntries = injectEffectEntries();
395
+ reducer = injectEffectReducer();
396
+ _effectMap;
397
+ root = inject(NgAtomicRootActionStore);
398
+ #destroyRef = inject(DestroyRef);
399
+ #el = inject(ElementRef);
193
400
  constructor() {
194
401
  super();
195
- this.root = inject(NgAtomicRootActionStore);
196
- this.#destroy$ = inject(DestroyRef);
197
- this.root.actions$.pipe(takeUntilDestroyed(this.#destroy$)).subscribe(action => this.#effect(action, 'root'));
402
+ this.root.actions$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(action => {
403
+ this.#effect(action, 'root');
404
+ });
198
405
  }
199
- dispatch(action, scope = 'default') {
200
- this.root.log(action, scope);
201
- const effect = this.#effect(action, scope);
406
+ async dispatch(action, scope = 'default', componentId = null) {
407
+ const selector = this.#el.nativeElement.tagName.toLowerCase();
408
+ const _action = { ...action, meta: { componentId, selector } };
409
+ const props = await this.reducer(_action);
410
+ if (props?.dispatch === false)
411
+ return;
412
+ const effect = this.#effect(_action, scope);
413
+ this.root.log(_action, scope);
202
414
  if (scope === 'root' && (!effect?.props || effect?.props?.dispatch)) {
203
- this.root.actions$.emit(action);
415
+ this.root.actions$.emit(_action);
204
416
  }
205
417
  else if (!effect?.props || effect?.props?.dispatch) {
206
- this.action.emit(action);
418
+ super.dispatch(_action);
207
419
  }
208
420
  }
209
421
  #effect(action, scope = 'default') {
210
422
  const effect = (this._effectMap ?? new EffectMap()).get(action.id, scope);
211
423
  if (effect?.key && effect?.props?.scope === scope) {
212
- this[effect?.key](effect.props.accessor(action));
424
+ this[effect.key](effect.props.accessor(action));
213
425
  }
214
426
  return effect;
215
427
  }
216
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgAtomicComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
217
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: NgAtomicComponent, isStandalone: true, usesInheritance: true, ngImport: i0 }); }
428
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: NgAtomicComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
429
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.2", type: NgAtomicComponent, isStandalone: true, usesInheritance: true, hostDirectives: [{ directive: DebugDirective }], ngImport: i0 });
218
430
  }
219
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgAtomicComponent, decorators: [{
431
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.2", ngImport: i0, type: NgAtomicComponent, decorators: [{
220
432
  type: Directive,
221
- args: [{ standalone: true }]
222
- }], ctorParameters: function () { return []; } });
433
+ args: [{
434
+ standalone: true,
435
+ hostDirectives: [
436
+ DebugDirective,
437
+ ],
438
+ }]
439
+ }], ctorParameters: () => [] });
223
440
 
224
441
  /**
225
442
  * Generated bundle index. Do not edit.
226
443
  */
227
444
 
228
- export { Effect, EffectMap, HostType, InjectableComponent, NgAtomicComponent, NgAtomicComponentStore, NgAtomicRootActionStore, getInputs, getInputsByComponentRef, getMeta, getOutputs, getOutputsByInstance, provideComponent, resolveActions };
445
+ export { CallPipe, DebugDirective, EFFECT_ENTRY, Effect, EffectMap, EffectReducer, FAKE_COMPUTED, HostType, InjectableComponent, NG_ATOMIC_DEBUG, NgAtomicComponent, NgAtomicRootActionStore, TOKEN, TokenizedType, _computed, compute, computeFake, fakeComputed, getInputs, getInputsByComponentRef, getMeta, getOutputs, getOutputsByInstance, getToken, injectEffectEntries, injectEffectReducer, isFakeComputed, provideComponent, provideEffect, proxyFakeComputedInputValueFn, proxyFakeComputedInputs, resolveActions, withNgAtomicDebug, wrapActions };
229
446
  //# sourceMappingURL=ng-atomic-core.mjs.map