@nordcraft/runtime 1.0.19 → 1.0.21

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/package.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "type": "module",
5
5
  "homepage": "https://github.com/nordcraftengine/nordcraft",
6
6
  "dependencies": {
7
- "@nordcraft/core": "1.0.19",
8
- "@nordcraft/std-lib": "1.0.19",
7
+ "@nordcraft/core": "1.0.21",
8
+ "@nordcraft/std-lib": "1.0.21",
9
9
  "fast-deep-equal": "3.1.3",
10
10
  "path-to-regexp": "6.3.0"
11
11
  },
@@ -21,5 +21,5 @@
21
21
  "files": ["dist", "src"],
22
22
  "main": "dist/page.main.js",
23
23
  "types": "dist/page.main.d.ts",
24
- "version": "1.0.19"
24
+ "version": "1.0.21"
25
25
  }
@@ -30,8 +30,12 @@ import {
30
30
  omitPaths,
31
31
  sortObjectEntries,
32
32
  } from '@nordcraft/core/dist/utils/collections'
33
- import { PROXY_URL_HEADER, validateUrl } from '@nordcraft/core/dist/utils/url'
34
- import { isDefined } from '@nordcraft/core/dist/utils/util'
33
+ import {
34
+ PROXY_TEMPLATES_IN_BODY,
35
+ PROXY_URL_HEADER,
36
+ validateUrl,
37
+ } from '@nordcraft/core/dist/utils/url'
38
+ import { isDefined, toBoolean } from '@nordcraft/core/dist/utils/util'
35
39
  import { handleAction } from '../events/handleAction'
36
40
  import type { Signal } from '../signal/signal'
37
41
  import type { ComponentContext, ContextApiV2 } from '../types'
@@ -411,6 +415,15 @@ export function createAPI({
411
415
  PROXY_URL_HEADER,
412
416
  decodeURIComponent(url.href.replace(/\+/g, ' ')),
413
417
  )
418
+ const allowBodyTemplateValues = toBoolean(
419
+ applyFormula(
420
+ api.server?.proxy?.useTemplatesInBody?.formula,
421
+ getFormulaContext(api, componentData),
422
+ ),
423
+ )
424
+ if (allowBodyTemplateValues) {
425
+ headers.set(PROXY_TEMPLATES_IN_BODY, 'true')
426
+ }
414
427
  requestSettings.headers = headers
415
428
  response = await fetch(proxyUrl, requestSettings)
416
429
  }
@@ -928,7 +941,9 @@ export function createAPI({
928
941
  requestSettings,
929
942
  componentData: initialComponentData,
930
943
  })
931
- } else {
944
+ } else if (!ctx.dataSignal.get().Apis?.[api.name]) {
945
+ // If the api is not set in the dataSignal, we need to initialize it.
946
+ // If it is set and autoFetch is false, we do not want to reset it.
932
947
  ctx.dataSignal.update((data) => {
933
948
  return {
934
949
  ...data,
@@ -102,7 +102,7 @@ type ToddlePreviewEvent =
102
102
  | { type: 'keyup'; key: string; altKey: boolean; metaKey: boolean }
103
103
  | {
104
104
  type: 'get_computed_style'
105
- styles: string[]
105
+ styles?: string[]
106
106
  }
107
107
  | {
108
108
  type: 'set_timeline_keyframes'
@@ -863,7 +863,7 @@ export const createRoot = (
863
863
  {
864
864
  type: 'computedStyle',
865
865
  computedStyle: Object.fromEntries(
866
- styles.map((style) => [
866
+ (styles ?? []).map((style) => [
867
867
  style,
868
868
  computedStyle.getPropertyValue(style),
869
869
  ]),