diff --git a/source b/source index 5ad958c1d2c..892120ea4ba 100644 --- a/source +++ b/source @@ -58417,10 +58417,11 @@ o............A....e
  • If this returns null, set the script's script to null and abort these substeps; the script is ready.

  • -
  • Fetch the - descendants of script (using an empty ancestor list). When this - asynchronously completes, set the script's - script to the result. At that time, the script is ready.

  • +
  • Fetch the + descendants of and instantiate script, given the destination "script". When this asynchronously completes, set the script's script to the result. At that time, + the script is ready.

  • @@ -87176,130 +87177,15 @@ interface NavigatorOnLine {
  • Assert: result's state is "uninstantiated".

  • -
  • -

    Fetch the - descendants of result given destination and an ancestor list - obtained by appending url to ancestor list. Wait for fetching the descendants of a module script to - asynchronously complete with descendants result before proceeding to the next step.

    - -

    If the asynchronous completion result is null, meaning that fetching one of the - descendants failed, we still proceed through the next set of steps. A failure will shortly occur - during instantiation, which we then react to appropriately. The error signal is eventually - propagated to the caller of this algorithm in the last step.

    -
  • - -
  • Let record be result's module record.

  • - -
  • -

    Let instantiationStatus be record.ModuleDeclarationInstantiation().

    - -

    This step will recursively call ModuleDeclarationInstantiation all of the - module's uninstantiated dependencies.

    -
  • +
  • Fetch the + descendants of and instantiate result given destination and an + ancestor list obtained by appending url to ancestor list.

  • -
  • -

    For each script in result's uninstantiated inclusive descendant - module scripts, perform the following steps:

    - -
      -
    1. If instantiationStatus is an abrupt completion, then error script with - instantiationStatus.[[Value]].

    2. - -
    3. Otherwise, set script's state to "instantiated".

    4. -
    -
  • - -
  • -

    Asynchronously complete this algorithm with descendants result.

    - -

    It is intentional that we complete with descendants result here, and - not result, as this allows us to propagate error signals to the caller.

    -
  • +
  • When the fetch the descendants of and instantiate a module script algorithm + asynchronously completes with final result, asynchronously complete this algorithm + with final result.

  • -

    In the above algorithm, a module script script's uninstantiated - inclusive descendant module scripts is a set of module scripts determined as follows:

    - -
      -
    1. If script's module - record is null, return the empty set.

    2. - -
    3. Let moduleMap be script's settings object's - module map.

    4. - -
    5. Let stack be the stack « script ».

    6. - -
    7. Let inclusive descendants be an empty set.

    8. - -
    9. -

      While stack is not empty:

      - -
        -
      1. Let current the result of popping from - stack.

      2. - -
      3. Assert: current is a module script (i.e., it is not "fetching" or null).

      4. - -
      5. -

        If inclusive descendants and stack both do not contain current, then:

        - -
          -
        1. Append current to - inclusive descendants.

        2. - -
        3. Let child specifiers be the value of current's module record's [[RequestedModules]] - internal slot.

        4. - -
        5. Let child URLs be the list obtained by calling - resolve a module specifier once for each item of child specifiers, - given current and that item. Omit any failures.

        6. - -
        7. Let child modules be the list obtained by getting each value in moduleMap whose key is given by an - item of child URLs.

        8. - -
        9. -

          For each s of child modules:

          - -
            -
          1. If inclusive descendants already contains s, continue.

          2. - -
          3. If s is null, continue.

          4. - -
          5. Assert: s is a module script (i.e., it is not - "fetching", since by this point all child modules must have been - fetched).

          6. - -
          7. Push s onto stack.

          8. -
          -
        -
      6. -
      -
    10. - -
    11. Return a set containing all items of inclusive descendants whose - state is "uninstantiated".

    12. -
    - -

    The above algorithm gives a depth-first search of the module dependency graph. The - main interesting part is in how the "edges" of this graph are determined. The actual search - implementation is not important; any other technique for exploring the graph will suffice, given - that the output is a set only used for membership testing and whose order is thus not - important.

    -

    To fetch a single module script, given a url, a fetch client settings object, a destination, a cryptographic nonce, a parser state, a credentials mode, a module map settings object, a @@ -87395,12 +87281,21 @@ interface NavigatorOnLine { -

    To fetch the descendants of a module script module script, given a - destination and an ancestor list, run these steps. The algorithm will - asynchronously complete with either null (on failure) or with module script (on - success).

    +

    To fetch the descendants of and instantiate a module script module + script, given a destination and an optional ancestor list, run these + steps. The algorithm will asynchronously complete with either null (on failure) or with + module script (on success).

      +
    1. If ancestor list was not given, let it be the empty list.

    2. + +
    3. If module script's state is + "instantiated" or "errored", asynchronously + complete this algorithm with module script, and abort these steps.

    4. + +
    5. Assert: module script's state + is "uninstantiated".

    6. +
    7. Let record be module script's module record.

    8. @@ -87437,6 +87332,8 @@ interface NavigatorOnLine {
    +
  • Let descendants result be null.

  • +
  • For each url in urls, perform the internal module script graph fetching procedure given url, module @@ -87454,24 +87351,132 @@ interface NavigatorOnLine { be performed in parallel to each other.

    If any invocation of the internal module script graph fetching procedure - asynchronously completes with null, optionally abort all other invocations, and then - asynchronously complete this algorithm with null.

    + asynchronously completes with null, then optionally abort all other invocations, set + descendants result to null, and proceed to the next step. (The un-fetched descendant + will cause errors during instantiation.)

    If any invocation of the internal module script graph fetching procedure asynchronously completes with a module script whose state is "errored", - optionally abort all other invocations, and then asynchronously complete this algorithm with - module script. (The errored descendant will cause errors later in the module-fetching - process, but for now we treat it as a premature "success".)

    + data-x="concept-module-script-state">state is "errored", then + optionally abort all other invocations, set descendants result to module + script, and proceed to the next step. (The errored descendant will cause errors during + instantiation.)

    Otherwise, wait for all of the internal module script graph fetching procedure invocations to asynchronously complete, with module scripts whose states are not "errored". Then, asynchronously complete this algorithm with module - script.

    + data-x="">errored". Then, set descendants result to module script, + and proceed to the next step.

    +
  • + +
  • +

    Let instantiationStatus be record.ModuleDeclarationInstantiation().

    + +

    This step will recursively call ModuleDeclarationInstantiation all of the + module's uninstantiated dependencies.

    +
  • + +
  • +

    For each script in module script's uninstantiated inclusive + descendant module scripts, perform the following steps:

    + +
      +
    1. If instantiationStatus is an abrupt completion, then error script with + instantiationStatus.[[Value]].

    2. + +
    3. Otherwise, set script's state to "instantiated".

    4. +
    +
  • + +
  • +

    Asynchronously complete this algorithm with descendants result.

    + +

    It is intentional that we complete with descendants result here, and + not module script, as this allows us to notify the caller of fetching errors.

    +
  • + + +

    In the above algorithm, a module script script's uninstantiated + inclusive descendant module scripts is a set of module scripts determined as follows:

    + +
      +
    1. If script's module + record is null, return the empty set.

    2. + +
    3. Let moduleMap be script's settings object's + module map.

    4. + +
    5. Let stack be the stack « script ».

    6. + +
    7. Let inclusive descendants be an empty set.

    8. + +
    9. +

      While stack is not empty:

      + +
        +
      1. Let current the result of popping from + stack.

      2. + +
      3. Assert: current is a module script (i.e., it is not "fetching" or null).

      4. + +
      5. +

        If inclusive descendants and stack both do not contain current, then:

        + +
          +
        1. Append current to + inclusive descendants.

        2. + +
        3. Let child specifiers be the value of current's module record's [[RequestedModules]] + internal slot.

        4. + +
        5. Let child URLs be the list obtained by calling + resolve a module specifier once for each item of child specifiers, + given current and that item. Omit any failures.

        6. + +
        7. Let child modules be the list obtained by getting each value in moduleMap whose key is given by an + item of child URLs.

        8. + +
        9. +

          For each s of child modules:

          + +
            +
          1. If inclusive descendants already contains s, continue.

          2. + +
          3. If s is null, continue.

          4. + +
          5. Assert: s is a module script (i.e., it is not + "fetching", since by this point all child modules must have been + fetched).

          6. + +
          7. Push s onto stack.

          8. +
          +
        +
      6. +
    10. + +
    11. Return a set containing all items of inclusive descendants whose + state is "uninstantiated".

    +

    The above algorithm gives a depth-first search of the module dependency graph. The + main interesting part is in how the "edges" of this graph are determined. The actual search + implementation is not important; any other technique for exploring the graph will suffice, given + that the output is a set only used for membership testing and whose order is thus not + important.

    +
    Creating scripts

    To create a classic script, given some script