@fluffjs/fluff 0.1.15 → 0.1.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluffjs/fluff",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -76,6 +76,9 @@ export class FluffBase extends HTMLElement {
76
76
  }
77
77
  __applyPipes(value, pipes, locals) {
78
78
  let result = value;
79
+ if (result instanceof Property) {
80
+ result = result.getValue();
81
+ }
79
82
  for (const pipe of pipes) {
80
83
  result = this.__applyPipe(pipe.n, result, pipe.a, locals);
81
84
  }
@@ -0,0 +1,6 @@
1
+ import { FluffElement } from '../FluffElementImpl.js';
2
+ export interface PipeUnwrapChildComponentInstance extends FluffElement {
3
+ value: unknown;
4
+ }
5
+ export type PipeUnwrapChildComponentConstructor = new () => PipeUnwrapChildComponentInstance;
6
+ export declare function createPipeUnwrapChildComponent(): PipeUnwrapChildComponentConstructor;
@@ -0,0 +1,10 @@
1
+ import { FluffElement } from '../FluffElementImpl.js';
2
+ export function createPipeUnwrapChildComponent() {
3
+ class ChildComponent extends FluffElement {
4
+ value = null;
5
+ __render() {
6
+ this.__getShadowRoot().innerHTML = '<span>child</span>';
7
+ }
8
+ }
9
+ return ChildComponent;
10
+ }
@@ -0,0 +1,12 @@
1
+ import { Property } from '../../utils/Property.js';
2
+ import { FluffElement } from '../FluffElementImpl.js';
3
+ export interface PipeUnwrapTestState {
4
+ receivedValue: unknown;
5
+ receivedValueType: string;
6
+ }
7
+ export interface PipeUnwrapParentComponentInstance extends FluffElement {
8
+ testProp: number;
9
+ __testProp: Property<number>;
10
+ }
11
+ export type PipeUnwrapParentComponentConstructor = new () => PipeUnwrapParentComponentInstance;
12
+ export declare function createPipeUnwrapParentComponent(state: PipeUnwrapTestState, childTag: string): PipeUnwrapParentComponentConstructor;
@@ -0,0 +1,24 @@
1
+ import { Property } from '../../utils/Property.js';
2
+ import { FluffElement } from '../FluffElementImpl.js';
3
+ export function createPipeUnwrapParentComponent(state, childTag) {
4
+ class ParentComponent extends FluffElement {
5
+ __testProp = new Property({ initialValue: 99, propertyName: 'testProp' });
6
+ get testProp() {
7
+ return this.__testProp.getValue() ?? 0;
8
+ }
9
+ set testProp(val) {
10
+ this.__testProp.setValue(val);
11
+ }
12
+ __pipes = {
13
+ capture: (value) => {
14
+ state.receivedValue = value;
15
+ state.receivedValueType = value instanceof Property ? 'Property' : typeof value;
16
+ return value;
17
+ }
18
+ };
19
+ __render() {
20
+ this.__getShadowRoot().innerHTML = `<${childTag} data-lid="l0"></${childTag}>`;
21
+ }
22
+ }
23
+ return ParentComponent;
24
+ }
@@ -0,0 +1,12 @@
1
+ import { Property } from '../../utils/Property.js';
2
+ import { FluffElement } from '../FluffElementImpl.js';
3
+ export interface PipeUnwrapTestState {
4
+ receivedValue: unknown;
5
+ receivedValueType: string;
6
+ }
7
+ export interface PipeUnwrapTestComponentInstance extends FluffElement {
8
+ testProp: number;
9
+ __testProp: Property<number>;
10
+ }
11
+ export type PipeUnwrapTestComponentConstructor = new () => PipeUnwrapTestComponentInstance;
12
+ export declare function createPipeUnwrapTestComponent(state: PipeUnwrapTestState): PipeUnwrapTestComponentConstructor;
@@ -0,0 +1,32 @@
1
+ import { Property } from '../../utils/Property.js';
2
+ import { FluffElement } from '../FluffElementImpl.js';
3
+ import { MarkerManager } from '../MarkerManager.js';
4
+ export function createPipeUnwrapTestComponent(state) {
5
+ class TestComponent extends FluffElement {
6
+ __testProp = new Property({ initialValue: 42, propertyName: 'testProp' });
7
+ get testProp() {
8
+ return this.__testProp.getValue() ?? 0;
9
+ }
10
+ set testProp(val) {
11
+ this.__testProp.setValue(val);
12
+ }
13
+ __pipes = {
14
+ capture: (value) => {
15
+ state.receivedValue = value;
16
+ state.receivedValueType = value instanceof Property ? 'Property' : typeof value;
17
+ return value;
18
+ }
19
+ };
20
+ __render() {
21
+ this.__getShadowRoot().innerHTML = '<span><!--fluff:text:0--><!--/fluff:text:0--></span>';
22
+ this.__setMarkerConfigs(JSON.stringify([
23
+ [0, { type: 'text', exprId: 0, deps: ['testProp'], pipes: [{ name: 'capture', argExprIds: [] }] }]
24
+ ]));
25
+ }
26
+ __setupBindings() {
27
+ this.__initializeMarkers(MarkerManager);
28
+ super.__setupBindings();
29
+ }
30
+ }
31
+ return TestComponent;
32
+ }