@jxsuite/runtime 6.1.0 → 6.2.0

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.
package/dist/runtime.js CHANGED
@@ -2790,11 +2790,22 @@ async function resolve(source, ctx) {
2790
2790
  if (contentType.includes("text/html")) {
2791
2791
  throw new Error(`Jx: ${source} returned HTML, not a document — the host answered a missing file with its ` + `app shell (a single-page fallback), so this path is not served.`);
2792
2792
  }
2793
+ if (JXN_URL.test(source) && !contentType.includes("json")) {
2794
+ if (!_documentParser) {
2795
+ throw new Error(`Jx: ${source} is a .jxn file and this page has no parser for it. Serve it from a Jx ` + `site, which answers JSON, or call setDocumentParser(parseJxn) with parseJxn from ` + `@jxsuite/schema/jxn.`);
2796
+ }
2797
+ return _documentParser(await res.text(), source);
2798
+ }
2793
2799
  return await res.json();
2794
2800
  });
2795
2801
  _resolveCache.set(source, p);
2796
2802
  return p;
2797
2803
  }
2804
+ var JXN_URL = /\.jxn(?:[?#]|$)/iu;
2805
+ var _documentParser = null;
2806
+ function setDocumentParser(parser) {
2807
+ _documentParser = parser;
2808
+ }
2798
2809
  var SCHEMA_KEYWORDS2 = new Set([
2799
2810
  "type",
2800
2811
  "properties",
@@ -3379,7 +3390,27 @@ var RESERVED_KEYS = new Set([
3379
3390
  "observedAttributes"
3380
3391
  ]);
3381
3392
  function inheritScope(parent) {
3382
- return Object.create(parent);
3393
+ const local = Object.create(parent);
3394
+ return new Proxy(local, {
3395
+ set(target, key, value) {
3396
+ if (Object.hasOwn(target, key)) {
3397
+ return Reflect.set(target, key, value);
3398
+ }
3399
+ if (key in parent) {
3400
+ return Reflect.set(parent, key, value);
3401
+ }
3402
+ bindLocal(target, key, value);
3403
+ return true;
3404
+ }
3405
+ });
3406
+ }
3407
+ function bindLocal(scope, key, value) {
3408
+ Object.defineProperty(scope, key, {
3409
+ configurable: true,
3410
+ enumerable: true,
3411
+ value,
3412
+ writable: true
3413
+ });
3383
3414
  }
3384
3415
  function scopeMedia(state) {
3385
3416
  return state["$media"] ?? {};
@@ -3425,7 +3456,7 @@ function renderNode(def, state, options) {
3425
3456
  if (localState === state) {
3426
3457
  localState = inheritScope(state);
3427
3458
  }
3428
- localState[key] = isRef2(val) ? resolveRef(val.$ref, state) : val;
3459
+ bindLocal(localState, key, isRef2(val) ? resolveRef(val.$ref, state) : val);
3429
3460
  }
3430
3461
  }
3431
3462
  if ("$ref" in def && !def.tagName) {
@@ -3956,7 +3987,7 @@ function renderMappedArrayInto(parentEl, arrayDef, state, options) {
3956
3987
  const createRow = (key, item, index) => {
3957
3988
  const map = shallowReactive({ index, item });
3958
3989
  const child = inheritScope(state);
3959
- child.$map = map;
3990
+ bindLocal(child, "$map", map);
3960
3991
  Object.defineProperty(child, "$map/item", { enumerable: true, get: () => map.item });
3961
3992
  Object.defineProperty(child, "$map/index", { enumerable: true, get: () => map.index });
3962
3993
  const scope = effectScope(true);
@@ -4737,7 +4768,7 @@ function mergeProps(def, parentState) {
4737
4768
  if (refusePrivateProp(k, "$props")) {
4738
4769
  continue;
4739
4770
  }
4740
- child[k] = isRef2(v) ? resolveRef(v.$ref, parentState) : v;
4771
+ bindLocal(child, k, isRef2(v) ? resolveRef(v.$ref, parentState) : v);
4741
4772
  }
4742
4773
  return child;
4743
4774
  }
@@ -5320,6 +5351,7 @@ export {
5320
5351
  setCanvasDelinkCommands,
5321
5352
  setCanvasDelinkPopovers,
5322
5353
  setCanvasViewportTranspose,
5354
+ setDocumentParser,
5323
5355
  setNpmModuleResolver,
5324
5356
  setResolveToken,
5325
5357
  setRootMedia,
@@ -5335,5 +5367,5 @@ export {
5335
5367
  transposeCanvasUnits
5336
5368
  };
5337
5369
 
5338
- //# debugId=A334DCA3F0B40F7E64756E2164756E21
5370
+ //# debugId=16998FE20281F1D164756E2164756E21
5339
5371
  //# sourceMappingURL=runtime.js.map