@doenet/v06-to-v07 0.7.21-dev.360 → 0.7.21-dev.362

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42249,7 +42249,7 @@ async function cidFromArrayBuffer(data) {
42249
42249
  await crypto.subtle.digest("SHA-256", new Uint8Array());
42250
42250
  digest = (data2) => crypto.subtle.digest("SHA-256", data2);
42251
42251
  } catch (e22) {
42252
- const sha256 = (await import("./sha256-J35x7uWS-24B4oOm4-dXGg8bE3.js").then((n2) => n2.s)).default;
42252
+ const sha256 = (await import("./sha256-J35x7uWS-BmXeMLW9-DJX9SvnZ.js").then((n2) => n2.s)).default;
42253
42253
  digest = (data2) => sha256(data2, {
42254
42254
  asBytes: true
42255
42255
  });
@@ -45087,6 +45087,32 @@ function requireCssesc() {
45087
45087
  }
45088
45088
  requireCssesc();
45089
45089
  const data_format_version = "0.7.0";
45090
+ const DEFAULT_LOCALE = "en";
45091
+ function declaredDocumentLocale(authoredLang, hostLocale) {
45092
+ const tag2 = (authoredLang ?? "").trim() || (hostLocale ?? "").trim();
45093
+ if (tag2 === "") {
45094
+ return void 0;
45095
+ }
45096
+ return normalizeLocaleTag(tag2) || void 0;
45097
+ }
45098
+ function resolveDocumentLocale(authoredLang, hostLocale) {
45099
+ return declaredDocumentLocale(authoredLang, hostLocale) ?? DEFAULT_LOCALE;
45100
+ }
45101
+ function normalizeLocaleTag(tag2) {
45102
+ const trimmed = tag2.trim();
45103
+ if (trimmed === "") {
45104
+ return trimmed;
45105
+ }
45106
+ try {
45107
+ return new Intl.Locale(trimmed).toString();
45108
+ } catch {
45109
+ return trimmed;
45110
+ }
45111
+ }
45112
+ const DEFAULT_LOCALE_DATA = {
45113
+ locale: DEFAULT_LOCALE,
45114
+ resources: {}
45115
+ };
45090
45116
  function getVariantsForDescendantsForUniqueVariants({
45091
45117
  variantIndex,
45092
45118
  serializedComponent,
@@ -59584,6 +59610,13 @@ const _FlagDependency = class _FlagDependency2 extends ValueDependency {
59584
59610
  };
59585
59611
  _FlagDependency.dependencyType = "flag";
59586
59612
  let FlagDependency = _FlagDependency;
59613
+ const _LocaleDependency = class _LocaleDependency2 extends ValueDependency {
59614
+ setUpParameters() {
59615
+ this.value = this.dependencyHandler.core.localeData.locale;
59616
+ }
59617
+ };
59618
+ _LocaleDependency.dependencyType = "locale";
59619
+ let LocaleDependency = _LocaleDependency;
59587
59620
  const _DoenetAttributeDependency = class _DoenetAttributeDependency2 extends StateVariableDependency {
59588
59621
  setUpParameters() {
59589
59622
  this.attributeName = this.definition.attributeName;
@@ -60188,6 +60221,7 @@ const dependencyTypeClasses = [
60188
60221
  CountAmongSiblingsDependency,
60189
60222
  ValueDependency,
60190
60223
  FlagDependency,
60224
+ LocaleDependency,
60191
60225
  DoenetAttributeDependency,
60192
60226
  ExtendingDependency,
60193
60227
  AttributePrimitiveDependency,
@@ -69172,6 +69206,7 @@ class Core {
69172
69206
  requestedVariantIndex,
69173
69207
  initializeCounters = {},
69174
69208
  theme,
69209
+ localeData = DEFAULT_LOCALE_DATA,
69175
69210
  styleOverrides,
69176
69211
  prerender = false,
69177
69212
  stateVariableChanges: stateVariableChangesString,
@@ -69218,6 +69253,7 @@ class Core {
69218
69253
  this.numerics = new Numerics();
69219
69254
  this.flags = flags;
69220
69255
  this.theme = theme;
69256
+ this.localeData = localeData;
69221
69257
  this.styleOverrides = styleOverrides;
69222
69258
  this.getStateVariableValue = this.getStateVariableValue.bind(this);
69223
69259
  this.componentInfoObjects = componentInfoObjects2;
@@ -118601,6 +118637,10 @@ class Document extends BaseComponent {
118601
118637
  createPrimitiveOfType: "string",
118602
118638
  description: "Document type identifier."
118603
118639
  };
118640
+ attributes.lang = {
118641
+ createPrimitiveOfType: "string",
118642
+ description: `BCP-47 language tag for the document's content, e.g. "es" or "es-MX". Overrides the locale supplied by the hosting page.`
118643
+ };
118604
118644
  return attributes;
118605
118645
  }
118606
118646
  static returnChildGroups() {
@@ -118741,6 +118781,45 @@ class Document extends BaseComponent {
118741
118781
  }
118742
118782
  }
118743
118783
  };
118784
+ stateVariableDefinitions.locale = {
118785
+ description: "The BCP-47 language tag in effect for the document's content.",
118786
+ public: true,
118787
+ shadowingInstructions: {
118788
+ createComponentOfType: "text"
118789
+ },
118790
+ returnDependencies: () => ({
118791
+ lang: {
118792
+ dependencyType: "attributePrimitive",
118793
+ attributeName: "lang"
118794
+ },
118795
+ hostLocale: {
118796
+ dependencyType: "locale"
118797
+ },
118798
+ documentAncestor: {
118799
+ dependencyType: "ancestor",
118800
+ componentType: "document",
118801
+ variableNames: ["locale"]
118802
+ }
118803
+ }),
118804
+ definition({ dependencyValues }) {
118805
+ const lang = dependencyValues.lang?.trim();
118806
+ if (!lang && dependencyValues.documentAncestor) {
118807
+ return {
118808
+ setValue: {
118809
+ locale: dependencyValues.documentAncestor.stateValues.locale
118810
+ }
118811
+ };
118812
+ }
118813
+ return {
118814
+ setValue: {
118815
+ locale: resolveDocumentLocale(
118816
+ lang,
118817
+ dependencyValues.hostLocale
118818
+ )
118819
+ }
118820
+ };
118821
+ }
118822
+ };
118744
118823
  stateVariableDefinitions.level = {
118745
118824
  forRenderer: true,
118746
118825
  returnDependencies: () => ({}),
@@ -229698,6 +229777,7 @@ let PublicDoenetMLCore$1 = class PublicDoenetMLCore2 {
229698
229777
  this.initialized = false;
229699
229778
  this.doenetML = "";
229700
229779
  this.flags = {};
229780
+ this.localeData = DEFAULT_LOCALE_DATA;
229701
229781
  }
229702
229782
  setSource(doenetML) {
229703
229783
  this.doenetML = doenetML;
@@ -229705,6 +229785,16 @@ let PublicDoenetMLCore$1 = class PublicDoenetMLCore2 {
229705
229785
  setFlags(flags) {
229706
229786
  this.flags = flags;
229707
229787
  }
229788
+ /**
229789
+ * Set the content locale and the message catalogs to translate with.
229790
+ *
229791
+ * Catalogs arrive as plain FTL strings rather than URLs: the worker runs
229792
+ * from a blob or an inlined script depending on the bundling variant, and
229793
+ * cannot reliably resolve a relative fetch in all of them.
229794
+ */
229795
+ setLocaleData(localeData) {
229796
+ this.localeData = localeData;
229797
+ }
229708
229798
  async initializeWorker({
229709
229799
  activityId,
229710
229800
  docId,
@@ -229736,6 +229826,7 @@ let PublicDoenetMLCore$1 = class PublicDoenetMLCore2 {
229736
229826
  this.coreBaseArgs = {
229737
229827
  doenetML: this.doenetML,
229738
229828
  flags: this.flags,
229829
+ localeData: this.localeData,
229739
229830
  activityId,
229740
229831
  docId,
229741
229832
  requestedVariantIndex,
@@ -231861,4 +231952,4 @@ export {
231861
231952
  getDefaultExportFromCjs as g,
231862
231953
  updateSyntaxFromV06toV07 as u
231863
231954
  };
231864
- //# sourceMappingURL=index-BP-C-atu.js.map
231955
+ //# sourceMappingURL=index-DDdeu5On.js.map