Interactivity final class
Minn\Runtime\Interactivity · public/minn/src/Minn/Runtime/Interactivity.php · 534 lines
Server-side directive processing for the Interactivity API: the state and config stores, and the pass that resolves data-wp-bind, data-wp-class, data-wp-style, data-wp-text, and data-wp-each against state and context before the markup leaves the server. Behaviour pinned by the interactivity probe fixture.
Constants and properties
| private | VOID = array ( 0 => 'area', 1 => 'base', 2 => 'br', 3 => 'col', 4 => 'embed', 5 => 'hr', 6 => 'img', 7 => 'input', 8 => 'link', 9 => 'meta', 10 => 'source', 11 => 'track', 12 => 'wbr', ) | |
| private | RAW = array ( 0 => 'script', 1 => 'style', 2 => 'textarea', 3 => 'title', ) | |
| private | TAG = '/<(\\/?)([a-zA-Z][^\\s\\/>]*)((?:\\s+[^\\s=\\/>]+(?:\\s*=\\s*(?:"[^"]*"|\'[^\']*\'|[^\\s"\'>]+))?)*)\\s*(\\/?)>/' | |
| private | UNRESOLVED = '' . "\0" . 'unresolved' | |
| private | ATTR = '/\\s+([^\\s=\\/>]+)(?:\\s*=\\s*("[^"]*"|\'[^\']*\'|[^\\s"\'>]+))?/' | |
| private | array $state | |
| private | array $config | |
| private | array $namespaces | |
| private | array $contexts | |
| private | ?array $element | |
| private | bool $processing | |
| private | ?Closure $routerRegion |
Public
| method | whenRouterRegion(Closure $callback): void# | What to run when processing meets a router region. |
| method | state(?string $namespace, array $state = array ( )): array# | Reads or extends a namespace's state. @return array<string, mixed> |
| method | allState(): array# | Every namespace's state, for the client. @return array<string, array<string, mixed>> every namespace's state, for the client |
| method | allConfig(): array# | Every namespace's config, for the client. @return array<string, array<string, mixed>> |
| method | config(string $namespace, array $config = array ( )): array# | Reads or extends a namespace's config. @return array<string, mixed> |
| method | context(?string $namespace = NULL): array# | The current directive context of a namespace. @return array<string, mixed> |
| method | element(): ?array# | The element whose directives are being evaluated. @return array<string, mixed>|null |
| method | process(string $html): string# | HTML with its directives resolved on the server. |
Internals 15
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | namespace(): string# | |||||||
| private | tokenize(string $html): ?array# | Start tags, end tags, and everything between, with balance checked; null when the markup does not close what it opens. @return list<array{kind: string, start: int, end: int, name?: string, attrs?: list<array{name: string, value: ?string, start: int, end: int}>, void?: bool, close?: int}>|null | ||||||
| private | walk(array $tokens, string $html): ?string# |
| ||||||
| private | applyDirectives(array $token, string $tag, array $frame): string# |
| ||||||
| private | bind(Minn\Runtime\TagEditor $editor, string $attribute, string $path): void# | |||||||
| private | interactiveNamespace(string $value): ?string# | |||||||
| private | pushContext(string $value): void# | |||||||
| private | evaluate(string $reference, string $suffix): mixed# | The value a directive path names, or UNRESOLVED when the namespace or path is empty. | ||||||
| private | expandEach(array $each, array $tokens, int $closeIndex, string $html): string# |
| ||||||
| private | markChildren(string $fragment, string $reference): string# | Every top-level start tag in the fragment gains data-wp-each-child first. | ||||||
| private | attributeMap(array $attrs): array# |
@return array<string, mixed> | ||||||
| private | relative(array $attrs, int $base): array# |
@return list<array{name: string, value: ?string, start: int, end: int}> | ||||||
| private | escape(string $text): string# | |||||||
| private | camel(string $name): string# | |||||||
| private | follow(mixed $value, array $names): mixed# | A value reached through a path of keys or properties, or null from the first one that is not there.
|
Nothing matches.