Bot releases are visible (Hide)
Published by github-actions[bot] about 1 month ago
resolveValue
methoddeserializeControls
error callback.is
, deepEqual
and shallowEqual
predicates to the @makeswift/controls
packagePublished by github-actions[bot] about 1 month ago
Published by github-actions[bot] about 1 month ago
resolveValue
methodis
, deepEqual
and shallowEqual
predicates to the @makeswift/controls
packagePublished by github-actions[bot] about 2 months ago
Published by github-actions[bot] about 2 months ago
Shape
introspection and copying to properly handle non-existent/orphaned props.Published by github-actions[bot] about 2 months ago
Published by github-actions[bot] about 2 months ago
Shape
introspection and copying to properly handle non-existent/orphaned props.Published by github-actions[bot] about 2 months ago
deserializeControls
now handles deserialization issues more gracefully: the function attempts to deserialize all of the controls, reporting deserialization errors through an optional error callback.Select
options schema to allow values that can be coerced to a string.Published by github-actions[bot] about 2 months ago
Published by github-actions[bot] about 2 months ago
Select
options schema to allow values that can be coerced to a string.Published by github-actions[bot] 2 months ago
@makeswift/controls
package.Published by github-actions[bot] 2 months ago
30a7c9b: This change updates the runtime to use the latest version of
@makeswift/controls
. As part of this update, this package is no longer
exposing internal data types and functions associated with our controls.
Attempting to create a control with arbitrary configuration options will
now result in a TypeScript compilation error:
import { Number } from "@makeswift/runtime/controls";
const num = Number({ foo: "bar" }); // error, `foo` is not a valid `Number` param
Prior to this version, the arbitrary options were silently ignored.
The Select
control now requires options
to be a readonly array with at
least one entry. If you are not defining your options inline, you may need
to declare the options as const
.
import { Select } from "@makeswift/runtime/controls";
const sel = Select({
label: "Select",
options: [], // error, non-empty array is required
});
Previously, the options
array was allowed to be empty.
Published by github-actions[bot] 2 months ago
30a7c9b: This change converts our control definitions to active classes, each with
encapsulated implementations for control serialization/deserialization, data and
value parsing, copying, and other core operations for controls.
In addition, base definitions of all controls, as well as several shared
types/schemas, have now been defined in this package.
Several types and utilities associated with controls have been removed as part of
this change. As an example, let's look over the types/functions associated with
the Color
control (keep in mind that this applies to all controls, not just
Color
):
ColorControlType
: a string literal identifying the Color
controlColorControlDataTypeValueV1
- a string literal identifying V1 Color controlColorControlDataTypeKey
: a string literal defining the key in which the V1ColorControlDataV0
/ ColorControlDataV1
- types describing the data formatColorControlData
- describes the data format for a Color
control. In thisColorControlDataV0
andColorControlDataV1
ColorControlDefinition
- describes the type of the Color
controlcopyColorData
- Creates a copy of a given ColorControlData
, given a copyAll of these have been removed. Most of them have been replaced by
functionality available on the ColorDefinition
active class. Let's see how
we can use this class to achieve the functionality of the removed constructs
above:
import { type DataType, Color, ColorDefinition } from '@makeswift/controls`
const color = Color({ defaultValue: "red" })
// Accessing config information:
console.log(color.config)
type ColorControlType = ColorDefinition['controlType']
type ColorControlData = DataType<ColorDefinition> // a union of V1 and V0 data
// Copying Data:
color.copyData({ swatchId: '###', alpha: 1 }, ...)
Note the use of the DataType
type, which can infer the data type given a
control definition. Also note that the copyData
method is defined on an
instance of a color, rather than a standalone function.
Published by github-actions[bot] 3 months ago
Published by github-actions[bot] 3 months ago
2a5e096: Add a link
command.
The link
command will allow users with an existing Next.js site to link it to a Makeswift site. This command does nothing in terms of setting up Makeswift pages or using the client inside the Next.js site - that part is expected to already be done upon use of this command.
Published by github-actions[bot] 3 months ago
REGISTER_BUILDER_DOCUMENT
event during initialize()
. This is used to inform the builder which document or element tree to subscribe to.Published by github-actions[bot] 3 months ago
Published by github-actions[bot] 4 months ago
"publishedAt"
sort option for getPages
, which results in a"description"
.Published by github-actions[bot] 4 months ago
75cf3fd: BREAKING: The latest upgrade to the Makeswift client getPages
method
introduces sorting, path filtering, and pagination. This method was not
previously paginated - in order to get all your pages, you may now use our
toArray
pagination helper method, which will automatically paginate through
all results and aggregate them into an array:
import { client } from "@/makeswift/client";
import { MakeswiftPage } from "@makeswift/runtime/next";
async function getAllPages(): Promise<MakeswiftPage[]> {
return await client.getPages().toArray();
}
getPages
now returns an instance of IterablePaginationResult
, a decorated
async iterator which includes methods .map
and .filter
, in addition to
.toArray
, mentioned above.
This change also deprecates the client getSitemap
method, with the
recommendation that sitemaps should now be generated using data returned from
getPages
. Note that the deprecation of getSitemap
now involves the host
being responsible for the construction of page paths in the sitemap (either with
domain or path based localization). Below is an example that uses path-based
localization with the next-sitemap
library:
import { getServerSideSitemapLegacy } from "next-sitemap";
import { MakeswiftPage } from "@makeswift/runtime/next";
import { client } from "@makeswift/client";
const DOMAIN = "https://example.com";
const DEFAULT_PRIORITY = 0.75;
const DEFAULT_FREQUENCY = "hourly";
function pageToSitemapItem(page: MakeswiftPage) {
const pageUrl = new URL(page.path, DOMAIN);
return {
loc: pageUrl.href,
lastmod: page.createdAt,
changefreq: page.sitemapFrequency ?? DEFAULT_FREQUENCY,
priority: page.sitemapPriority ?? DEFAULT_PRIORITY,
alternateRefs: page.localizedVariants.map((variant) => {
const localizedPath = `/${variant.locale}/${variant.path}`;
const localizedPageUrl = new URL(localizedPath, DOMAIN);
return {
hreflang: variant.locale,
href: localizedPageUrl.href,
};
}),
};
}
export async function getServerSideProps(context) {
const sitemap = client
.getPages()
.filter((page) => !page.excludedFromSearch)
.map((page) => pageToSitemapItem(page))
.toArray();
return getServerSideSitemapLegacy(context, sitemap);
}
export default function Sitemap() {}
Here's another example for Next.js's App Router built-in support for sitemaps:
import { MetadataRoute } from "next";
import { MakeswiftPage } from "@makeswift/runtime/dist/types/next";
import { client } from "@/lib/makeswift/client";
type NextSitemapItem = MetadataRoute.Sitemap[number];
const DOMAIN = "https://example.com";
const DEFAULT_PRIORITY = 0.75;
const DEFAULT_FREQUENCY = "hourly";
function pageToSitemapEntry(page: MakeswiftPage): NextSitemapItem {
const pageUrl = new URL(page.path, DOMAIN);
return {
url: pageUrl.href,
lastModified: page.createdAt,
changeFrequency: page.sitemapFrequency ?? DEFAULT_FREQUENCY,
priority: page.sitemapPriority ?? DEFAULT_PRIORITY,
};
}
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
return client
.getPages()
.filter((page) => !page.excludedFromSearch)
.map((page) => pageToSitemapEntry(page))
.toArray();
}
BREAKING: The exported MakeswiftPage
type now includes several more data
fields from the Makeswift page.
Published by github-actions[bot] 5 months ago