Skip to content

Commit

Permalink
Merge pull request #1597 from lowdefy/develop
Browse files Browse the repository at this point in the history
Release v4.0.0-rc.9
  • Loading branch information
Gervwyk committed May 31, 2023
2 parents 8f3a651 + 2a61c7f commit 09f6ece
Show file tree
Hide file tree
Showing 34 changed files with 466 additions and 320 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/routes/request/callRequest.test.js
Expand Up @@ -352,7 +352,7 @@ test('deserialize inputs', async () => {
await callRequest(context, {
blockId: 'contextId',
payload: {
date: { _date: 0 },
date: { '~d': 0 },
},
pageId: 'pageId',
requestId: 'requestId',
Expand Down
8 changes: 4 additions & 4 deletions packages/build/src/build/addKeys.js
Expand Up @@ -22,16 +22,16 @@ function recAddKeys(object, key, keyMap, parentId) {
const id = makeId();
keyMap[id] = {
key,
_r_: object._r_,
_k_parent: parentId,
'~r': object['~r'],
'~k_parent': parentId,
};
Object.defineProperty(object, '_k_', {
Object.defineProperty(object, '~k', {
value: id,
enumerable: false,
writable: true,
configurable: true,
});
delete object._r_;
delete object['~r'];
Object.keys(object).forEach((nextKey) => {
if (type.isObject(object[nextKey])) {
recAddKeys(object[nextKey], `${key}.${nextKey}`, keyMap, id);
Expand Down
62 changes: 31 additions & 31 deletions packages/build/src/build/addKeys.test.js
Expand Up @@ -22,84 +22,84 @@ const context = testContext();
test('mutate keyMap and components', async () => {
const addKeys = (await import('./addKeys.js')).default;
const components = {
_r_: '1',
'~r': '1',
pages: [
{
id: 'A',
type: 'Box',
_r_: '2',
'~r': '2',
blocks: [
{ _r_: '3', id: 'A1', type: 'Button' },
{ _r_: '7', id: 'A2', type: 'Button' },
{ '~r': '3', id: 'A1', type: 'Button' },
{ '~r': '7', id: 'A2', type: 'Button' },
],
},
{
id: 'B',
type: 'Box',
_r_: '5',
'~r': '5',
blocks: [
{ _r_: '4', id: 'B1', type: 'Button' },
{ _r_: '6', id: 'B2', type: 'Button', properties: { _r_: '10', title: 'X' } },
{ '~r': '4', id: 'B1', type: 'Button' },
{ '~r': '6', id: 'B2', type: 'Button', properties: { '~r': '10', title: 'X' } },
],
},
],
};
addKeys({ components, context });
expect(context.keyMap).toEqual({
2: {
_k_parent: '1',
_r_: '1',
'~k_parent': '1',
'~r': '1',
key: 'root',
},
3: {
_k_parent: '2',
_r_: '2',
'~k_parent': '2',
'~r': '2',
key: 'root.pages[0:A:Box]',
},
4: {
_k_parent: '3',
_r_: '3',
'~k_parent': '3',
'~r': '3',
key: 'root.pages[0:A:Box].blocks[0:A1:Button]',
},
5: {
_k_parent: '3',
_r_: '7',
'~k_parent': '3',
'~r': '7',
key: 'root.pages[0:A:Box].blocks[1:A2:Button]',
},
6: {
_k_parent: '2',
_r_: '5',
'~k_parent': '2',
'~r': '5',
key: 'root.pages[1:B:Box]',
},
7: {
_k_parent: '6',
_r_: '4',
'~k_parent': '6',
'~r': '4',
key: 'root.pages[1:B:Box].blocks[0:B1:Button]',
},
8: {
_k_parent: '6',
_r_: '6',
'~k_parent': '6',
'~r': '6',
key: 'root.pages[1:B:Box].blocks[1:B2:Button]',
},
9: {
_k_parent: '8',
_r_: '10',
'~k_parent': '8',
'~r': '10',
key: 'root.pages[1:B:Box].blocks[1:B2:Button].properties',
},
});
expect(JSON.parse(serializer.serializeToString(components))).toEqual({
_k_: '2',
'~k': '2',
pages: [
{
_k_: '3',
'~k': '3',
blocks: [
{
_k_: '4',
'~k': '4',
id: 'A1',
type: 'Button',
},
{
_k_: '5',
'~k': '5',
id: 'A2',
type: 'Button',
},
Expand All @@ -108,19 +108,19 @@ test('mutate keyMap and components', async () => {
type: 'Box',
},
{
_k_: '6',
'~k': '6',
blocks: [
{
_k_: '7',
'~k': '7',
id: 'B1',
type: 'Button',
},
{
_k_: '8',
'~k': '8',
id: 'B2',
type: 'Button',
properties: {
_k_: '9',
'~k': '9',
title: 'X',
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/build/buildRefs/recursiveBuild.js
Expand Up @@ -76,7 +76,7 @@ async function recursiveBuild({ context, refDef, count, referencedFrom }) {

const reviver = (_, value) => {
if (!type.isObject(value)) return value;
Object.defineProperty(value, '_r_', {
Object.defineProperty(value, '~r', {
value: refDef.id,
enumerable: false,
writable: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/docs/migration/v3-to-v4.yaml
Expand Up @@ -209,6 +209,8 @@ _ref:
The `_format` operator has been replaced with the [`_intl`](/_intl) and [`_moment`](/_moment) operator, with some minor schema changes.
The format of dates in the output of the [`_json.stringify`](/_json) and [`_yaml.stringify`](/_yaml) operators, as well as in URL query parameters has changed from `_date: {iso_date_string}` to `~d: {iso_date_string}`.
## Block Loading States
The page loading states in version 4 have been improved. In general apps should load a lot faster. Blocks will now be a lot less likely to show a loading state and rather render as normal, and render their children. Input blocks will be disabled while in a loading state. This contributes to users seeing useful content sooner, and to less layout shifts once the app finishes loading.
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/src/Blocks.js
Expand Up @@ -237,7 +237,7 @@ class Blocks {
blockValue = type.isUndefined(block.meta.initValue)
? type.enforceType(block.meta.valueType, null)
: block.meta.initValue;
this.context._internal.State.set(block.blockId, block.value);
this.context._internal.State.set(block.blockId, blockValue);
}
if (block.meta.category === 'list') {
// load list value into list blocks
Expand Down

2 comments on commit 09f6ece

@vercel
Copy link

@vercel vercel bot commented on 09f6ece May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lowdefy-website – ./packages/server

lowdefy-website.vercel.app
lowdefy-website-lowdefy.vercel.app
lowdefy-website-git-main-lowdefy.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 09f6ece May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./packages/server

docs-v4.lowdefy.app
docs-lowdefy.vercel.app
docs-phi-ten.vercel.app
docs-git-main-lowdefy.vercel.app

Please sign in to comment.