@nordcraft/runtime 1.0.18 → 1.0.20

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,13 +4,13 @@
4
4
  "type": "module",
5
5
  "homepage": "https://github.com/nordcraftengine/nordcraft",
6
6
  "dependencies": {
7
- "@nordcraft/core": "1.0.18",
8
- "@nordcraft/std-lib": "1.0.18",
7
+ "@nordcraft/core": "1.0.20",
8
+ "@nordcraft/std-lib": "1.0.20",
9
9
  "fast-deep-equal": "3.1.3",
10
10
  "path-to-regexp": "6.3.0"
11
11
  },
12
12
  "devDependencies": {
13
- "@happy-dom/global-registrator": "17.4.7"
13
+ "@happy-dom/global-registrator": "17.5.6"
14
14
  },
15
15
  "scripts": {
16
16
  "build": "tsc && bun scripts/build.js",
@@ -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.18"
24
+ "version": "1.0.20"
25
25
  }
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-floating-promises */
2
2
  import type { LegacyComponentAPI } from '@nordcraft/core/dist/api/apiTypes'
3
+ import { mapHeadersToObject } from '@nordcraft/core/dist/api/headers'
3
4
  import type { ComponentData } from '@nordcraft/core/dist/component/component.types'
4
5
  import { applyFormula, isFormula } from '@nordcraft/core/dist/formula/formula'
5
6
  import { mapValues } from '@nordcraft/core/dist/utils/collections'
@@ -362,10 +363,7 @@ export function createLegacyAPI(
362
363
  url: request?.url ?? apiPayload.url,
363
364
  method: request?.method ?? apiPayload.method,
364
365
  auth: request?.auth ?? apiPayload.auth,
365
- headers: [...headers.entries()].reduce<Record<string, string>>(
366
- (acc, [key, value]) => ({ ...acc, [key]: value }),
367
- {},
368
- ),
366
+ headers: mapHeadersToObject(headers),
369
367
  body,
370
368
  }
371
369
  return trigger(payload)
@@ -17,6 +17,7 @@ import {
17
17
  isJsonHeader,
18
18
  isJsonStreamHeader,
19
19
  isTextHeader,
20
+ mapHeadersToObject,
20
21
  } from '@nordcraft/core/dist/api/headers'
21
22
  import type { ComponentData } from '@nordcraft/core/dist/component/component.types'
22
23
  import type {
@@ -29,8 +30,12 @@ import {
29
30
  omitPaths,
30
31
  sortObjectEntries,
31
32
  } from '@nordcraft/core/dist/utils/collections'
32
- import { PROXY_URL_HEADER, validateUrl } from '@nordcraft/core/dist/utils/url'
33
- 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'
34
39
  import { handleAction } from '../events/handleAction'
35
40
  import type { Signal } from '../signal/signal'
36
41
  import type { ComponentContext, ContextApiV2 } from '../types'
@@ -410,6 +415,15 @@ export function createAPI({
410
415
  PROXY_URL_HEADER,
411
416
  decodeURIComponent(url.href.replace(/\+/g, ' ')),
412
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
+ }
413
427
  requestSettings.headers = headers
414
428
  response = await fetch(proxyUrl, requestSettings)
415
429
  }
@@ -582,7 +596,7 @@ export function createAPI({
582
596
  error: null,
583
597
  response: {
584
598
  status: res.status,
585
- headers: Object.fromEntries(res.headers.entries()),
599
+ headers: mapHeadersToObject(res.headers),
586
600
  },
587
601
  }
588
602
  return endResponse({ api, apiStatus: status, componentData, performance })
@@ -607,7 +621,7 @@ export function createAPI({
607
621
  error: null,
608
622
  response: {
609
623
  status: res.status,
610
- headers: Object.fromEntries(res.headers.entries()),
624
+ headers: mapHeadersToObject(res.headers),
611
625
  },
612
626
  }
613
627
  return endResponse({ api, apiStatus: status, componentData, performance })
@@ -700,7 +714,7 @@ export function createAPI({
700
714
  data: parseChunksForData(this.chunks),
701
715
  error: null,
702
716
  response: {
703
- headers: Object.fromEntries(res.headers.entries()),
717
+ headers: mapHeadersToObject(res.headers),
704
718
  },
705
719
  },
706
720
  },
@@ -754,7 +768,7 @@ export function createAPI({
754
768
  error: null,
755
769
  response: {
756
770
  status: res.status,
757
- headers: Object.fromEntries(res.headers.entries()),
771
+ headers: mapHeadersToObject(res.headers),
758
772
  },
759
773
  }
760
774
 
@@ -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
  ]),