@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/dist/api/createAPI.js +2 -1
- package/dist/api/createAPI.js.map +1 -1
- package/dist/api/createAPIv2.js +11 -7
- package/dist/api/createAPIv2.js.map +1 -1
- package/dist/custom-element.main.esm.js +21 -21
- package/dist/custom-element.main.esm.js.map +4 -4
- package/dist/editor-preview.main.js +1 -1
- package/dist/editor-preview.main.js.map +1 -1
- package/dist/page.main.esm.js +3 -3
- package/dist/page.main.esm.js.map +4 -4
- package/package.json +4 -4
- package/src/api/createAPI.ts +2 -4
- package/src/api/createAPIv2.ts +20 -6
- package/src/editor-preview.main.ts +2 -2
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.
|
|
8
|
-
"@nordcraft/std-lib": "1.0.
|
|
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.
|
|
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.
|
|
24
|
+
"version": "1.0.20"
|
|
25
25
|
}
|
package/src/api/createAPI.ts
CHANGED
|
@@ -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:
|
|
366
|
-
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
367
|
-
{},
|
|
368
|
-
),
|
|
366
|
+
headers: mapHeadersToObject(headers),
|
|
369
367
|
body,
|
|
370
368
|
}
|
|
371
369
|
return trigger(payload)
|
package/src/api/createAPIv2.ts
CHANGED
|
@@ -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 {
|
|
33
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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
|
]),
|