How to prevent page break for included file with same numbering rule?

lib.typ:

#let temp(doc) = {
    set page(numbering: "1")
    doc
}

The question is I want to let if I only compile a.typ or b.typ I still can have numbering rule.

one option is to edit temp to check if the numbering has already been applied, and if so exit early:

#let temp(doc) = context {
  let numbering-pattern = "1"
  if page.numbering == numbering-pattern {
    return doc
  }
  set page(numbering: numbering-pattern)
  doc
}

But the problem isn’t unique to numbering, it applies to any page show/set rule. Knowing this, it may be tedious to check if an arbitrary rule has already been applied so an alternative could be to add a unique label to the main heading, and make all other files first check that label exists:

#let temp(doc) = context {
  let numbering-pattern = "1"
  if page.numbering == numbering-pattern {
    return doc
  }
  set page(numbering: numbering-pattern)
  doc
}

#let temp2(doc) = context {
  let vals = query(label("unique"))
  if vals != () {
    return doc
  }
  show: temp
  doc
}

#show: temp

== main<unique>

#[
  // a.typ
  #show: temp2
  == a
]

#[
  // b.typ
  #show: temp2
  == b
]