@burger-editor/client 4.0.0-alpha.75 → 4.0.0-alpha.77

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.
Files changed (46) hide show
  1. package/dist/burger-editor-root.d.ts +1 -1
  2. package/dist/client.js +10720 -10434
  3. package/dist/client.js.map +1 -1
  4. package/dist/components/block-catalog.d.ts +1 -1
  5. package/dist/components/block-menu-button.d.ts +1 -1
  6. package/dist/components/block-menu-view.d.ts +1 -1
  7. package/dist/components/block-menu.d.ts +1 -1
  8. package/dist/components/block-menu.d.ts.map +1 -1
  9. package/dist/components/block-options.d.ts +1 -1
  10. package/dist/components/draft-switcher.d.ts +1 -1
  11. package/dist/components/editable-area-view.d.ts +1 -1
  12. package/dist/components/editable-area-view.d.ts.map +1 -1
  13. package/dist/components/file-list.d.ts +1 -1
  14. package/dist/components/file-uploader.d.ts +1 -1
  15. package/dist/components/front-matter-editor.d.ts +1 -1
  16. package/dist/components/initial-insertion-button.d.ts +1 -1
  17. package/dist/components/item-editor-host.d.ts +1 -1
  18. package/dist/components/preview.d.ts +1 -1
  19. package/dist/components/table-editor.d.ts +1 -1
  20. package/dist/components/tabs.d.ts +1 -1
  21. package/dist/components/thumbnail.d.ts +1 -1
  22. package/dist/components/wysiwyg-field.d.ts +1 -1
  23. package/dist/{editable-area-view-DssYcTqQ.js → editable-area-view-BRYT222Y.js} +174 -159
  24. package/dist/editable-area-view-BRYT222Y.js.map +1 -0
  25. package/dist/editor-dialog.d.ts +1 -1
  26. package/dist/{engine-context-gX6mWHke.js → engine-context-j4-LLPEh.js} +248 -74
  27. package/dist/engine-context-j4-LLPEh.js.map +1 -0
  28. package/dist/engine-context.d.ts +9 -6
  29. package/dist/engine-context.d.ts.map +1 -1
  30. package/dist/file-browser/store.d.ts +5 -0
  31. package/dist/file-browser/store.d.ts.map +1 -1
  32. package/dist/form/checkbox.d.ts +1 -1
  33. package/dist/form/fieldset.d.ts +1 -1
  34. package/dist/form/number-field.d.ts +1 -1
  35. package/dist/form/radio-group.d.ts +1 -1
  36. package/dist/form/select-field.d.ts +1 -1
  37. package/dist/form/text-area.d.ts +1 -1
  38. package/dist/form/text-field.d.ts +1 -1
  39. package/dist/root-error-boundary.d.ts +1 -1
  40. package/dist/testing/render-with-engine.d.ts +1 -1
  41. package/dist/testing.js +1 -1
  42. package/dist/ui.js +20 -10
  43. package/dist/ui.js.map +1 -1
  44. package/package.json +11 -11
  45. package/dist/editable-area-view-DssYcTqQ.js.map +0 -1
  46. package/dist/engine-context-gX6mWHke.js.map +0 -1
@@ -62,6 +62,24 @@ var CSS_LAYER = {
62
62
  };
63
63
  var BLOCK_OPTION_CSS_CUSTOM_PROPERTY_PREFIX = "--bge-options-";
64
64
  var BLOCK_OPTION_SCOPE_SELECTOR = `[data-bge-container]`;
65
+ /**
66
+ * Stand-in for an empty custom property value (`--x: ;`).
67
+ *
68
+ * Browsers keep such a declaration with the value `' '`, and project CSS
69
+ * relies on it to hide a built-in style option, but jsdom drops it while
70
+ * parsing, so a lower-priority declaration of the same property would win
71
+ * instead. Code that loads CSS into jsdom (file-io's
72
+ * `createStylesheetDocument()`) writes this value in its place, and
73
+ * `getCustomProperties` treats it the same as an empty value.
74
+ * @example
75
+ * ```ts
76
+ * const css = '[data-bge-container] { --bge-options-margin--none: ; }'.replace(
77
+ * ': ;',
78
+ * `: ${EMPTY_CUSTOM_PROPERTY_VALUE};`,
79
+ * );
80
+ * ```
81
+ */
82
+ var EMPTY_CUSTOM_PROPERTY_VALUE = "--bge-empty-custom-property-value";
65
83
  //#endregion
66
84
  //#region ../core/dist/dom-helpers/sanitize-attrs.js
67
85
  var removeAttrNameIgnoreList = /* @__PURE__ */ new Set([
@@ -274,21 +292,64 @@ function exportContainerProps(containerPropsQuery) {
274
292
  };
275
293
  }
276
294
  //#endregion
295
+ //#region ../core/dist/block/parse-style-option-name.js
296
+ /**
297
+ * Split a style option custom property name into its category and key.
298
+ *
299
+ * `--bge-options-{category}` (the selected-value declaration) yields
300
+ * `key: null`; `--bge-options-{category}--{key}` (a choice) yields both.
301
+ * Option detection and the read-back of saved HTML both split through this
302
+ * function, so a name is offered as a choice exactly when it can be read
303
+ * back. Names that cannot be split unambiguously return `null`: an empty
304
+ * category or key, or more than one `--` after the prefix. Characters are
305
+ * otherwise not restricted.
306
+ * @param property - Custom property name, including the leading `--`
307
+ * @returns The category and key, or `null` when `property` is not a style
308
+ * option name
309
+ */
310
+ function parseStyleOptionName(property) {
311
+ if (!property.startsWith("--bge-options-")) return null;
312
+ const segments = property.slice(BLOCK_OPTION_CSS_CUSTOM_PROPERTY_PREFIX.length).split("--");
313
+ const [category, key] = segments;
314
+ if (!category || segments.length > 2 || key === "") return null;
315
+ return {
316
+ category,
317
+ key: key ?? null
318
+ };
319
+ }
320
+ //#endregion
277
321
  //#region ../core/dist/block/export-style-options.js
278
322
  /**
323
+ * Read the selected style options back from a block container's inline
324
+ * `style`.
279
325
  *
280
- * @param el
326
+ * Each `--bge-options-{category}: var(--bge-options-{category}--{key})`
327
+ * declaration becomes `{ [category]: key }`, which is the inverse of
328
+ * `importStyleOptions`. Names are split the same way the editor's option
329
+ * detection splits them, so any category and key the editor offers as a
330
+ * choice round-trips, whatever characters they use. Names containing `--`
331
+ * (or a category ending in `-`) cannot be split unambiguously and are
332
+ * ignored, as are declarations whose `var()` points at another category or
333
+ * that are not a single `var()` reference.
334
+ * @param el - Block container element whose inline `style` holds the options
335
+ * @returns Map of category to selected key
336
+ * @example
337
+ * ```ts
338
+ * el.setAttribute('style', '--bge-options-gap: var(--bge-options-gap--2x)');
339
+ * exportStyleOptions(el); // { gap: '2x' }
340
+ * ```
281
341
  */
282
342
  function exportStyleOptions(el) {
283
343
  const style = {};
284
344
  const decl = el.style;
285
345
  for (let i = 0; i < decl.length; i++) {
286
346
  const property = decl.item(i);
287
- if (!property.startsWith("--bge-options-")) continue;
288
- const category = property.replace(BLOCK_OPTION_CSS_CUSTOM_PROPERTY_PREFIX, "");
289
- const [, _category, propName] = el.style.getPropertyValue(property).replace(`var(--bge-options-`, "").replace(/\)$/, "").match(/^((?:_[a-z]+_)?[a-z]+(?:-[a-z]+)*)--([a-z]+(?:-[a-z]+)*)$/) ?? [];
290
- if (category !== _category || !propName) continue;
291
- style[category] = propName;
347
+ const declared = parseStyleOptionName(property);
348
+ if (!declared || declared.key !== null) continue;
349
+ const reference = /^var\(\s*([^\s(),]+)\s*\)$/.exec(decl.getPropertyValue(property).trim())?.[1];
350
+ const referenced = reference ? parseStyleOptionName(reference) : null;
351
+ if (referenced?.key == null || referenced.category !== declared.category) continue;
352
+ style[declared.category] = referenced.key;
292
353
  }
293
354
  return style;
294
355
  }
@@ -3922,6 +3983,51 @@ function stringifyField(fieldName, propName) {
3922
3983
  //#endregion
3923
3984
  //#region ../frozen-patty/dist/set-component.js
3924
3985
  /**
3986
+ * `picture` 内の `source` で無効な、`img` 専用の属性。
3987
+ * `source` で有効な属性の allowlist にしないのは、グローバル属性・`data-*`・
3988
+ * `aria-*` を列挙しきれず、取りこぼすと正しい属性まで落としてしまうため
3989
+ */
3990
+ var PICTURE_SOURCE_INVALID_ATTRS = [
3991
+ "alt",
3992
+ "src",
3993
+ "loading",
3994
+ "decoding",
3995
+ "fetchpriority",
3996
+ "crossorigin",
3997
+ "referrerpolicy",
3998
+ "usemap",
3999
+ "ismap",
4000
+ "elementtiming",
4001
+ "attributionsrc",
4002
+ "align",
4003
+ "border",
4004
+ "hspace",
4005
+ "vspace",
4006
+ "longdesc",
4007
+ "name",
4008
+ "lowsrc"
4009
+ ];
4010
+ /**
4011
+ * `picture` 内の `img` で無効な、`source` 専用の属性
4012
+ */
4013
+ var PICTURE_IMG_INVALID_ATTRS = ["media", "type"];
4014
+ /**
4015
+ * 要素から指定した属性を取り除く
4016
+ *
4017
+ * replaceNode は未バインドの静的属性を要素の種類に関係なく引き継ぎ、
4018
+ * 変換元と変換先の要素が同じ場合は何もしない。そのため、雛形 img の静的な
4019
+ * alt が source に付いたり、過去の出力で img に付いた media が残ったりする。
4020
+ * 変換の有無にかかわらず、ここで必ず落とす。
4021
+ * バインドされたフィールドは落とさない。要素のプロパティに無い属性は
4022
+ * setValue が書き込まないため(propInElement)、データの index 対応を
4023
+ * 崩してまで data-* 宣言から外す必要がない
4024
+ * @param el
4025
+ * @param names
4026
+ */
4027
+ function removeAttrs(el, names) {
4028
+ for (const name of names) el.removeAttribute(name);
4029
+ }
4030
+ /**
3925
4031
  *
3926
4032
  * @param el
3927
4033
  * @param data
@@ -3956,12 +4062,14 @@ function setComponent(el, data, attr, filter, xssSanitize = true) {
3956
4062
  let fields = getFields(item, attr);
3957
4063
  if (i === 0) {
3958
4064
  item = replaceNode(item, "img", attr, xssSanitize);
4065
+ removeAttrs(item, PICTURE_IMG_INVALID_ATTRS);
3959
4066
  fields = replaceProp(fields, "srcset", "src");
3960
4067
  fields = removeProp(fields, "sizes");
3961
4068
  const fieldQuery = stringifyFields(fields);
3962
4069
  item.setAttribute(`data-${attr}`, fieldQuery);
3963
4070
  } else {
3964
4071
  item = replaceNode(item, "source", attr, xssSanitize);
4072
+ removeAttrs(item, PICTURE_SOURCE_INVALID_ATTRS);
3965
4073
  fields = replaceProp(fields, "src", "srcset");
3966
4074
  fields = removeProp(fields, "alt");
3967
4075
  fields = removeProp(fields, "loading");
@@ -4660,7 +4768,7 @@ var CommandBus = class {
4660
4768
  * stay stable and readable across a test run or a debugging session.
4661
4769
  * Uniqueness holds only within one loaded copy of this module — the same
4662
4770
  * caveat as the `BurgerBlock`/`Item` module-level registries documented
4663
- * in ARCHITECTURE.md § 不変条件と否定的知識 applies here too.
4771
+ * in ARCHITECTURE.md § 不変条件と負の知識 applies here too.
4664
4772
  */
4665
4773
  receiverId = `${COMMAND_BUS_ID}-${++receiverSequence}`;
4666
4774
  #detachers = /* @__PURE__ */ new Map();
@@ -4741,31 +4849,26 @@ function createStylesheet(cssContents, layer) {
4741
4849
  return URL.createObjectURL(blob);
4742
4850
  }
4743
4851
  //#endregion
4744
- //#region ../core/dist/dom-helpers/create-component-stylesheet.js
4852
+ //#region ../core/dist/dom-helpers/editor-stylesheet-texts.js
4745
4853
  /**
4746
- *
4747
- * @param items
4748
- * @param generalCSS
4749
- * @param layer
4854
+ * The first two texts of {@link editorStylesheetTexts}: the layer order
4855
+ * statement and the base layer. Separate so the engine can create them
4856
+ * before it fetches `config.stylesheets`.
4857
+ * @param items - Item seeds whose `style` is loaded
4858
+ * @param generalCSS - Shared block CSS
4750
4859
  */
4751
- function createComponentStylesheet(items, generalCSS, layer) {
4752
- return createStylesheet(Object.values(items).map((item) => item.style).filter(Boolean).join("\n") + "\n" + generalCSS, layer);
4860
+ function editorBaseStylesheetTexts(items, generalCSS) {
4861
+ const itemStyles = Object.values(items).map((item) => item.style).filter(Boolean).join("\n");
4862
+ return [`@layer ${CSS_LAYER.base}, ${CSS_LAYER.components}, ${CSS_LAYER.ui};`, `@layer ${CSS_LAYER.base} {${itemStyles}\n${generalCSS}}`];
4753
4863
  }
4754
- //#endregion
4755
- //#region ../core/dist/dom-helpers/create-stylesheet-from-url.js
4756
4864
  /**
4757
- *
4758
- * @param url
4759
- * @param layer
4865
+ * One `config.stylesheets` entry as {@link editorStylesheetTexts} places it.
4866
+ * @param css - Stylesheet contents
4867
+ * @param layer - Cascade layer; the components layer when omitted, and no
4868
+ * layer at all for `''`
4760
4869
  */
4761
- async function createStylesheetFromUrl(url, layer) {
4762
- const cssContents = await (await fetch(url)).text();
4763
- const css = layer ? `@layer ${layer} {${cssContents}}` : cssContents;
4764
- const blob = new Blob([css], { type: "text/css" });
4765
- return {
4766
- blob: URL.createObjectURL(blob),
4767
- originalUrl: url
4768
- };
4870
+ function editorProjectStylesheetText(css, layer = CSS_LAYER.components) {
4871
+ return layer ? `@layer ${layer} {${css}}` : css;
4769
4872
  }
4770
4873
  //#endregion
4771
4874
  //#region ../core/dist/utils/compare-priority.js
@@ -4799,19 +4902,30 @@ function comparePriority(a, b) {
4799
4902
  //#endregion
4800
4903
  //#region ../core/dist/dom-helpers/get-custom-properties.js
4801
4904
  /**
4802
- * Get all custom properties from document
4905
+ * Get all `--bge-options-*` custom properties from document, grouped by
4906
+ * category. See the file-level comment for the detection rules.
4907
+ *
4908
+ * Inside the editor, call `engine.getCustomProperties()` instead; this
4909
+ * free function is for scanning a document the engine does not own, such
4910
+ * as stylesheets loaded into a jsdom document on Node.
4803
4911
  * @param scope - Document to scan for CSS custom properties
4804
4912
  * @param containerType - Container type to filter container-scoped properties (prefixed with `_`)
4805
4913
  * @returns Categorized map of custom properties grouped by property name
4914
+ * @example
4915
+ * ```ts
4916
+ * for (const [id, category] of getCustomProperties(document, 'grid')) {
4917
+ * console.log(id, [...category.properties.keys()]); // 'margin' ['none', 'small', ...]
4918
+ * }
4919
+ * ```
4806
4920
  */
4807
4921
  function getCustomProperties(scope, containerType) {
4808
4922
  const categories = /* @__PURE__ */ new Map();
4809
4923
  const defaultValues = /* @__PURE__ */ new Map();
4810
4924
  const nestedDefaultValues = /* @__PURE__ */ new Map();
4811
4925
  searchCustomProperty(scope, (cssProperty, value, layers, isNested) => {
4812
- if (!cssProperty.startsWith("--bge-options-")) return;
4813
- const [propName, key] = cssProperty.slice(BLOCK_OPTION_CSS_CUSTOM_PROPERTY_PREFIX.length).split("--");
4814
- if (!propName) return;
4926
+ const parsed = parseStyleOptionName(cssProperty);
4927
+ if (!parsed) return;
4928
+ const { category: propName, key } = parsed;
4815
4929
  if (propName.startsWith("_") && !propName.startsWith(`_${containerType}_`)) return;
4816
4930
  const currentMap = categories.get(propName) ?? {
4817
4931
  id: propName,
@@ -4838,7 +4952,10 @@ function getCustomProperties(scope, containerType) {
4838
4952
  targetMap.set(propName, currentDefaultValue ? compareCustomPropertyByLayerPriority(currentDefaultValue, newDefaultValue) : newDefaultValue);
4839
4953
  }
4840
4954
  });
4841
- for (const propList of categories.values()) for (const [key, customProperty] of propList.properties.entries()) if (customProperty.value.trim() === "") propList.properties.delete(key);
4955
+ for (const propList of categories.values()) for (const [key, customProperty] of propList.properties.entries()) {
4956
+ const value = customProperty.value.trim();
4957
+ if (value === "" || value === "--bge-empty-custom-property-value") propList.properties.delete(key);
4958
+ }
4842
4959
  for (const [category, nestedProperty] of nestedDefaultValues.entries()) {
4843
4960
  const directProperty = defaultValues.get(category);
4844
4961
  if (directProperty) {
@@ -4972,9 +5089,11 @@ function searchCustomProperty(scope, found) {
4972
5089
  const selector = rawSelector.replace(/^&/, "").trim();
4973
5090
  if (selector === BLOCK_OPTION_SCOPE_SELECTOR || selector === ":scope" && cssRule.scopeRoot === BLOCK_OPTION_SCOPE_SELECTOR) {
4974
5091
  const isNested = rawSelector !== selector;
4975
- for (const cssProperty of cssRule.rule.style) {
5092
+ const declarations = cssRule.rule.style;
5093
+ for (let i = 0; i < declarations.length; i++) {
5094
+ const cssProperty = declarations.item(i);
4976
5095
  if (!cssProperty.startsWith("--")) continue;
4977
- found(cssProperty, cssRule.rule.style.getPropertyValue(cssProperty), cssRule.layers, isNested);
5096
+ found(cssProperty, declarations.getPropertyValue(cssProperty), cssRule.layers, isNested);
4978
5097
  }
4979
5098
  }
4980
5099
  }
@@ -4984,9 +5103,18 @@ function searchCustomProperty(scope, found) {
4984
5103
  }
4985
5104
  }
4986
5105
  /**
4987
- * Get repeat-min-inline-size variant definitions from document
5106
+ * Get repeat-min-inline-size variant definitions from document. Uses the
5107
+ * same detection rules as `getCustomProperties`, except that empty values
5108
+ * are not filtered out.
5109
+ *
5110
+ * Inside the editor, call `engine.getRepeatMinInlineSizeVariants()` instead.
4988
5111
  * @param scope - Document to scan for `--bge-repeat-min-inline-size` variants
4989
5112
  * @returns Category containing variant properties, or `null` if no variants found
5113
+ * @example
5114
+ * ```ts
5115
+ * const presets = getRepeatMinInlineSizeVariants(document);
5116
+ * const keys = presets ? [...presets.properties.keys()] : []; // ['small', 'medium', 'large']
5117
+ * ```
4990
5118
  */
4991
5119
  function getRepeatMinInlineSizeVariants(scope) {
4992
5120
  const PREFIX = "--bge-repeat-min-inline-size";
@@ -5963,6 +6091,29 @@ var BurgerEditorEngine = class BurgerEditorEngine {
5963
6091
  if (!currentBlock) console.warn("block is unselected.");
5964
6092
  return currentBlock;
5965
6093
  }
6094
+ /**
6095
+ * List the block style options (`--bge-options-{category}--{key}`)
6096
+ * declared on `[data-bge-container]` in the stylesheets loaded into the
6097
+ * current editable area's document. This is what the block options
6098
+ * dialog renders as its style-option selects.
6099
+ *
6100
+ * The stylesheets are scanned on every call (no caching), so the result
6101
+ * reflects whatever is loaded at that moment. Detection rules (traversed
6102
+ * at-rules, layer priority, empty-value exclusion, default resolution)
6103
+ * are documented in
6104
+ * `dom-helpers/get-custom-properties.ts`.
6105
+ * @param containerType - Also include categories prefixed `_{containerType}_`
6106
+ * (e.g. `_grid_subgrid-gap` for `'grid'`); without it they are omitted
6107
+ * @returns Map keyed by category id; each category's `properties` maps
6108
+ * the key to its resolved `value` and whether it is the CSS default
6109
+ * @example
6110
+ * ```ts
6111
+ * for (const [id, category] of engine.getCustomProperties('grid')) {
6112
+ * const keys = [...category.properties.keys()];
6113
+ * console.log(id, category.name, keys); // '_grid_subgrid-gap' 'subgrid-gap' [...]
6114
+ * }
6115
+ * ```
6116
+ */
5966
6117
  getCustomProperties(containerType) {
5967
6118
  return getCustomProperties(this.#current.containerElement.ownerDocument, containerType);
5968
6119
  }
@@ -6014,6 +6165,27 @@ var BurgerEditorEngine = class BurgerEditorEngine {
6014
6165
  getLiveBlocks() {
6015
6166
  return listLiveBlocks(this.#current);
6016
6167
  }
6168
+ /**
6169
+ * List the grid wrap-width presets (`--bge-repeat-min-inline-size--{key}`)
6170
+ * declared on `[data-bge-container]` in the current editable area's
6171
+ * document, used for the auto-fit / auto-fill "wrap width" select.
6172
+ *
6173
+ * Uses the same detection rules as {@link getCustomProperties}, except
6174
+ * that empty values are not filtered out. The default is the key
6175
+ * referenced by `--bge-repeat-min-inline-size: var(...)`. Each preset
6176
+ * also needs a selector rule in CSS that maps the container's
6177
+ * `--{key}` option to the variable; `general.css` ships it only for
6178
+ * `small` / `medium` / `large`.
6179
+ * @returns The preset category (id `'repeat-min-inline-size'`), or `null`
6180
+ * when no preset is declared
6181
+ * @example
6182
+ * ```ts
6183
+ * const presets = engine.getRepeatMinInlineSizeVariants();
6184
+ * const defaultKey = presets
6185
+ * ? [...presets.properties].find(([, p]) => p.isDefault)?.[0]
6186
+ * : undefined; // 'medium' with the bundled general.css
6187
+ * ```
6188
+ */
6017
6189
  getRepeatMinInlineSizeVariants() {
6018
6190
  return getRepeatMinInlineSizeVariants(this.#current.containerElement.ownerDocument);
6019
6191
  }
@@ -6149,34 +6321,23 @@ var BurgerEditorEngine = class BurgerEditorEngine {
6149
6321
  }
6150
6322
  }
6151
6323
  static async #finishConstruction(engine, options) {
6152
- const layers = createStylesheet(`@layer ${CSS_LAYER.base}, ${CSS_LAYER.components}, ${CSS_LAYER.ui};`);
6153
- engine.#disposables.defer(() => {
6154
- URL.revokeObjectURL(layers);
6155
- });
6156
- const baseStylesheet = createComponentStylesheet(options.items, options.generalCSS, CSS_LAYER.base);
6157
- engine.#disposables.defer(() => {
6158
- URL.revokeObjectURL(baseStylesheet);
6159
- });
6160
- const componentStylesheets = await Promise.all(options.config.stylesheets.map(async (stylesheet) => {
6161
- return createStylesheetFromUrl(stylesheet.path, stylesheet.layer ?? CSS_LAYER.components);
6324
+ const createDisposableStylesheet = (css, id) => {
6325
+ const path = createStylesheet(css);
6326
+ engine.#disposables.defer(() => {
6327
+ URL.revokeObjectURL(path);
6328
+ });
6329
+ return {
6330
+ path,
6331
+ id
6332
+ };
6333
+ };
6334
+ const [layerOrderCss, baseCss] = editorBaseStylesheetTexts(options.items, options.generalCSS);
6335
+ const baseStylesheets = [createDisposableStylesheet(layerOrderCss, "layers"), createDisposableStylesheet(baseCss, "base-stylesheet")];
6336
+ const cssContents = await Promise.all(options.config.stylesheets.map(async (stylesheet) => {
6337
+ return (await fetch(stylesheet.path)).text();
6162
6338
  }));
6163
- for (const { blob } of componentStylesheets) engine.#disposables.defer(() => {
6164
- URL.revokeObjectURL(blob);
6165
- });
6166
- const stylesheets = [
6167
- {
6168
- path: layers,
6169
- id: "layers"
6170
- },
6171
- {
6172
- path: baseStylesheet,
6173
- id: "base-stylesheet"
6174
- },
6175
- ...componentStylesheets.map(({ blob, originalUrl }) => ({
6176
- path: blob,
6177
- id: originalUrl
6178
- }))
6179
- ];
6339
+ const componentStylesheets = options.config.stylesheets.map((stylesheet, index) => createDisposableStylesheet(editorProjectStylesheetText(cssContents[index], stylesheet.layer), stylesheet.path));
6340
+ const stylesheets = [...baseStylesheets, ...componentStylesheets];
6180
6341
  const mainInitialContent = typeof options.initialContents === "string" ? options.initialContents : options.initialContents.main;
6181
6342
  engine.#view = options.view ?? createDefaultView();
6182
6343
  engine.#disposables.use(engine.#view);
@@ -8464,7 +8625,7 @@ var require_omap = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8464
8625
  var _toString = Object.prototype.toString;
8465
8626
  function resolveYamlOmap(data) {
8466
8627
  if (data === null) return true;
8467
- var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
8628
+ var objectKeys = {}, index, length, pair, pairKey, pairHasKey, object = data;
8468
8629
  for (index = 0, length = object.length; index < length; index += 1) {
8469
8630
  pair = object[index];
8470
8631
  pairHasKey = false;
@@ -8474,8 +8635,8 @@ var require_omap = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8474
8635
  else return false;
8475
8636
  }
8476
8637
  if (!pairHasKey) return false;
8477
- if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
8478
- else return false;
8638
+ if (_hasOwnProperty.call(objectKeys, pairKey)) return false;
8639
+ Object.defineProperty(objectKeys, pairKey, { value: true });
8479
8640
  }
8480
8641
  return true;
8481
8642
  }
@@ -14083,6 +14244,7 @@ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14083
14244
  this.legacy = options["legacy"] || false;
14084
14245
  this.json = options["json"] || false;
14085
14246
  this.listener = options["listener"] || null;
14247
+ this.maxTotalMergeKeys = typeof options["maxTotalMergeKeys"] === "number" ? options["maxTotalMergeKeys"] : 1e4;
14086
14248
  this.implicitTypes = this.schema.compiledImplicit;
14087
14249
  this.typeMap = this.schema.compiledTypeMap;
14088
14250
  this.length = input.length;
@@ -14090,6 +14252,7 @@ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14090
14252
  this.line = 0;
14091
14253
  this.lineStart = 0;
14092
14254
  this.lineIndent = 0;
14255
+ this.totalMergeKeys = 0;
14093
14256
  this.documents = [];
14094
14257
  }
14095
14258
  function generateError(state, message) {
@@ -14138,12 +14301,18 @@ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14138
14301
  state.result += _result;
14139
14302
  }
14140
14303
  }
14304
+ function chargeMergeWork(state) {
14305
+ state.totalMergeKeys += 1;
14306
+ if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) throwError(state, "merge keys exceeded maxTotalMergeKeys (" + state.maxTotalMergeKeys + ")");
14307
+ }
14141
14308
  function mergeMappings(state, destination, source, overridableKeys) {
14142
14309
  var sourceKeys, key, index, quantity;
14143
14310
  if (!common.isObject(source)) throwError(state, "cannot merge mappings; the provided source object is unacceptable");
14311
+ chargeMergeWork(state);
14144
14312
  sourceKeys = Object.keys(source);
14145
14313
  for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
14146
14314
  key = sourceKeys[index];
14315
+ chargeMergeWork(state);
14147
14316
  if (!_hasOwnProperty.call(destination, key)) {
14148
14317
  setProperty(destination, key, source[key]);
14149
14318
  overridableKeys[key] = true;
@@ -14163,8 +14332,10 @@ var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14163
14332
  keyNode = String(keyNode);
14164
14333
  if (_result === null) _result = {};
14165
14334
  if (keyTag === "tag:yaml.org,2002:merge") {
14166
- if (Array.isArray(valueNode)) for (index = 0, quantity = valueNode.length; index < quantity; index += 1) mergeMappings(state, _result, valueNode[index], overridableKeys);
14167
- else mergeMappings(state, _result, valueNode, overridableKeys);
14335
+ if (Array.isArray(valueNode)) {
14336
+ if (valueNode.length > 100) throwError(state, "abnormal merge sequence size");
14337
+ for (index = 0, quantity = valueNode.length; index < quantity; index += 1) mergeMappings(state, _result, valueNode[index], overridableKeys);
14338
+ } else mergeMappings(state, _result, valueNode, overridableKeys);
14168
14339
  } else {
14169
14340
  if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
14170
14341
  state.line = startLine || state.line;
@@ -15717,9 +15888,9 @@ var EngineContext = createContext(null);
15717
15888
  * rendered under a `BurgerEditorRoot` / editable-area tree reads the engine
15718
15889
  * through {@link useEngine} instead of taking it as a prop — this is the
15719
15890
  * single dependency-injection point for the whole client UI.
15720
- * @param root0
15721
- * @param root0.engine
15722
- * @param root0.children
15891
+ * @param root0 - Provider props
15892
+ * @param root0.engine - The engine instance to expose to the subtree
15893
+ * @param root0.children - The subtree that reads the engine
15723
15894
  * @example
15724
15895
  * ```tsx
15725
15896
  * <EngineProvider engine={engine}>
@@ -15741,9 +15912,12 @@ function EngineProvider({ engine, children }) {
15741
15912
  * @throws {Error} When called outside an `EngineProvider`
15742
15913
  * @example
15743
15914
  * ```tsx
15744
- * function MyField() {
15745
- * const engine = useEngine();
15746
- * return <button onClick={() => engine.save()}>Save</button>;
15915
+ * function SamplePreview() {
15916
+ * const { config } = useEngine();
15917
+ * if (!config.sampleImagePath) {
15918
+ * return null;
15919
+ * }
15920
+ * return <img src={config.sampleImagePath} alt="" />;
15747
15921
  * }
15748
15922
  * ```
15749
15923
  */
@@ -15755,4 +15929,4 @@ function useEngine() {
15755
15929
  //#endregion
15756
15930
  export { UIStateStore as a, CommandBus as c, formatDate as d, CSS_LAYER as f, BurgerEditorEngine as i, Item as l, useEngine as n, createBgeEvent as o, getBlockAtPosition as r, beginProcessing as s, EngineProvider as t, formatByteSize as u };
15757
15931
 
15758
- //# sourceMappingURL=engine-context-gX6mWHke.js.map
15932
+ //# sourceMappingURL=engine-context-j4-LLPEh.js.map