ScriptModules final class
Minn\Runtime\ScriptModules · public/minn/src/Minn/Runtime/ScriptModules.php · 393 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 | array $told | |
| 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 | markedForEnqueue(): array# | The queued modules that are registered, in queue order, each as registered(): what the reference's get_marked_for_enqueue() answers, a module whose dependency is missing included. @return array<string, array{src: string, version: string|false|null, dependencies: list<array{id: string, import: string}>, in_footer: bool, fetchpriority: string}> | ||||||
| method | dependencyRecords(array $ids, array $types): array# | The registered dependencies of some modules, following the given import types, each as registered() (get_dependencies()).
@return array<string, array{src: string, version: string|false|null, dependencies: list<array{id: string, import: string}>, in_footer: bool, fetchpriority: string}> | ||||||
| method | source(string $id): string# | A registered module's address as the page loads it (get_src()); '' for one not registered. | ||||||
| method | printImportMap(): string# | The import map script tag. | ||||||
| method | printPreloads(): string# | The modulepreload links: the queued modules' static dependencies not queued themselves, each after its own (depth first, in queue order). | ||||||
| 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 10
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 | tellMissing(): void# | A queued module whose dependencies are not all registered is told once, as the page first prints its module tags or preloads, not as it registers (a dependency may be registered later). | ||||||
| private | dependenciesFirst(array $ids): array# | The modules' registered static dependencies, each after its own: depth first, in the order the modules and their dependencies are given.
@return list<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, following only the given import types: the modules' own dependencies in declaration order, then theirs, a level at a time (probe script-modules-private).
@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.