GeoLeaf Core API - v3.19.0
    Preparing search index...
    • May url be downloaded AHEAD of use — during the offline preparation — and from which origin does it come?

      A declaration prevails. An origin declared in modules.offline.dataOrigins — the page's own included — is allowed when it says cacheable: true and prefetch: true, and refused otherwise. An UNDECLARED origin is allowed only when it is the page's own: no third party is involved, and that origin cannot be written portably in a profile. Anything else is refused: an undeclared third-party origin, a declaration that only allows caching what was already served, an unparsable URL.

      ⚠️ Roles are NOT consulted. They route the Service Worker's cache; prefetch is the integrator's statement that the origin's terms allow downloading ahead of use, and it covers everything the profile needs from that origin — tiles, style, glyphs, sprite. One origin, one verdict: declaring the page's own origin for a same-origin data API alone — authenticated, or cacheable without prefetch — also refuses the tiles that origin serves.

      Parameters

      • url: string

        Resource URL, absolute or relative to pageUrl.

      • origins: readonly DataOriginDeclaration[]

        Normalised declarations (parseDataOrigins).

      • OptionalpageUrl: string

        The page's URL, which resolves a relative url and defines "own origin". Absent (no location), only a declared origin is allowed. The own origin is implicit only while it is undeclared.

      Returns PrefetchVerdict

      origin — the parsed origin, or the raw URL when it does not parse — and allowed. A refusal also says why, in reason: "undeclared" (a third-party origin no declaration names), "notPrefetchable" (declared, without cacheable: true and prefetch: true — an authenticated origin lands here, the flag being dropped from it) or "unparsable".

      const origins = parseDataOrigins(configGet("modules.offline.dataOrigins", []));
      const { allowed, origin } = prefetchVerdict(tileUrl, origins, globalThis.location?.href);
      if (!allowed) Log.warn(`Not downloaded: ${origin} is not declared for offline use`);