ScriptModules final class
Minn\Runtime\ScriptModules · public/minn/src/Minn/Runtime/ScriptModules.php · 303 lines
The script modules registry: registrations with typed dependencies, the queue, and the four things a page prints from it (the import map, module preloads, the module tags split head/footer, and per-module JSON data). Behaviour pinned by the script-modules probe fixture.
Constants and properties
| private | PRIORITIES = array ( 0 => 'high', 1 => 'low', 2 => 'auto', ) | |
| private | array $registered | |
| private | array $queue | |
| private | array $done | |
| private | bool $a11yAvailable | |
| private | bool $a11yPrinted | |
| private | readonly Closure $url | Promoted from the constructor. |
| private | readonly Closure $data | Promoted from the constructor. |
Public
| new | __construct(Closure $url, Closure $data)# |
| ||||||
| method | register(string $id, string $src, array $deps, string|false|null $version, array $args): void# | Registers a module by id.
| ||||||
| method | enqueue(string $id, string $src, array $deps, string|false|null $version, array $args): void# | Queues a module, registering it when a source is given. | ||||||
| method | dequeue(string $id): void# | Removes a module from the queue. | ||||||
| method | deregister(string $id): void# | Forgets a module. | ||||||
| method | setFetchpriority(string $id, string $priority): bool# | Sets a module's fetch priority. | ||||||
| method | moveToFooter(string $id): bool# | Moves a module to the footer or the head. | ||||||
| method | moveToHead(string $id): bool# | Prints a module in the head; false when it is not registered. | ||||||
| method | queue(): array# | The module ids queued. @return list<string> | ||||||
| method | registered(string $id): ?array# | One registered module, or null. @return array{src: string, version: string|false|null, dependencies: list<array{id: string, import: string}>, in_footer: bool, fetchpriority: string}|null | ||||||
| method | printImportMap(): string# | The import map script tag. | ||||||
| method | printPreloads(): string# | The modulepreload links. | ||||||
| method | printHead(): string# | The head's module tags. | ||||||
| method | printFooter(): string# | The footer's module tags. | ||||||
| method | printData(): string# | The script-module-data tags. | ||||||
| method | printA11y(): string# | The a11y module's tag, once. |
Internals 8
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | placeIn(string $id, string $where): bool# | |||||||
| private | printTags(bool $footer): string# | |||||||
| private | marked(): array# | Queued modules that are registered with every dependency registered, in queue order. | ||||||
| private | complete(string $id, array $seen): bool# |
| ||||||
| private | dependencies(array $ids, array $types): array# | Every registered dependency of the given modules, depth first in declaration order, following only the given import types.
@return list<string> | ||||||
| private | urlOf(string $id): string# | A module's address with its version, as plugins may change it (script_module_loader_src). | ||||||
| private | attr(string $value): string# | |||||||
| private | wrong(string $function, string $message, string $version): void# |
Nothing matches.