@inkandswitch/patchwork 0.7.2 → 0.7.4
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/CHANGELOG.md +36 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/repo.d.ts +2 -2
- package/dist/repo.js +3 -3
- package/dist/site-kit/html.js +13 -3
- package/dist/site-kit/options.d.ts +9 -1
- package/dist/types.d.ts +1 -1
- package/dist/vite/build-info-plugin.d.ts +1 -1
- package/dist/vite/build-info-plugin.js +1 -1
- package/dist/vite/config-plugin.d.ts +1 -1
- package/dist/vite/config-plugin.js +1 -1
- package/dist/vite/dev-plugin.d.ts +1 -1
- package/dist/vite/dev-plugin.js +1 -1
- package/dist/vite/html-plugin.d.ts +1 -1
- package/dist/vite/html-plugin.js +1 -1
- package/dist/vite/icons.d.ts +1 -1
- package/dist/vite/icons.js +1 -1
- package/dist/vite/importmap-plugin.js +14 -2
- package/dist/vite/manifest-plugin.d.ts +1 -1
- package/dist/vite/manifest-plugin.js +1 -1
- package/dist/vite/netlify-plugin.d.ts +1 -1
- package/dist/vite/netlify-plugin.js +1 -1
- package/dist/vite/patchwork-plugin.d.ts +10 -0
- package/dist/vite/patchwork-plugin.js +26 -16
- package/dist/vite/static-plugin.d.ts +1 -1
- package/dist/vite/static-plugin.js +1 -1
- package/package.json +50 -10
- package/src/index.ts +9 -8
- package/src/repo.ts +5 -5
- package/src/site-kit/html.ts +17 -3
- package/src/site-kit/options.ts +9 -1
- package/src/types.ts +1 -1
- package/src/vite/build-info-plugin.ts +1 -1
- package/src/vite/config-plugin.ts +1 -1
- package/src/vite/dev-plugin.ts +1 -1
- package/src/vite/html-plugin.ts +1 -1
- package/src/vite/icons.ts +1 -1
- package/src/vite/importmap-plugin.ts +14 -2
- package/src/vite/manifest-plugin.ts +1 -1
- package/src/vite/netlify-plugin.ts +1 -1
- package/src/vite/patchwork-plugin.ts +27 -16
- package/src/vite/static-plugin.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @inkandswitch/patchwork
|
|
2
2
|
|
|
3
|
+
## 0.7.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7339066: The dev importmap now names each builtin's pre-bundled dep URL
|
|
8
|
+
(`/node_modules/.vite/deps/…?v=…`) instead of `/@id/<dep>`. Both URLs resolve to
|
|
9
|
+
the same file, but a module fetched under two URLs is evaluated twice — the site
|
|
10
|
+
imported solid through the pre-bundled URL and tool code imported it through the
|
|
11
|
+
importmap, so tools ran against a second solid with its own owner stack and
|
|
12
|
+
logged "computations created outside a `createRoot`" for every effect they
|
|
13
|
+
created. Builtins that aren't pre-bundled still fall back to `/@id/<dep>`.
|
|
14
|
+
- ebca53b: Move the automerge-repo subduction fork to 2.6.0-subduction.48, `@automerge/automerge-repo-keyhive` to 0.5.0-alpha.7, and `@keyhive/keyhive` to 0.1.0-alpha.8. These three are bumped together because the keyhive package pins its automerge-repo version exactly.
|
|
15
|
+
|
|
16
|
+
keyhive 0.5 renames the two hive flavours. The network-adapter hive is now `LegacyAutomergeRepoKeyhive`, built by `initializeLegacyAutomergeRepoKeyhive`; the subduction hive keeps the name `AutomergeRepoKeyhive` and is built by `initializeAutomergeRepoKeyhive`. Both extend `AutomergeRepoKeyhiveBase`, which is what Patchwork's `hive` fields are typed as, so a tool that only reads membership works against either.
|
|
17
|
+
|
|
18
|
+
`createKeyhiveNetworkAdapter` takes an options object instead of positional arguments, and `onlyShareWithHardcodedServerPeerId` is now `onlyShareWithSyncServer`.
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [ebca53b]
|
|
21
|
+
- Updated dependencies [882eacd]
|
|
22
|
+
- @inkandswitch/patchwork-bootloader@0.6.3
|
|
23
|
+
- @inkandswitch/patchwork-elements@6.0.2
|
|
24
|
+
- @inkandswitch/patchwork-filesystem@0.2.8
|
|
25
|
+
- @inkandswitch/patchwork-plugins@1.2.3
|
|
26
|
+
- @inkandswitch/patchwork-providers@0.5.2
|
|
27
|
+
|
|
28
|
+
## 0.7.3
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- 8742cd2: Expose the individual vite plugins that `patchwork()` composes. Each one now has its own subpath — `@inkandswitch/patchwork/vite/importmap`, `/vite/service-worker`, `/vite/config`, `/vite/dev`, `/vite/icons`, `/vite/html`, `/vite/manifest`, `/vite/netlify`, `/vite/static`, `/vite/build-info` — and they are also re-exported from `@inkandswitch/patchwork/vite` as `importmap`, `serviceworker`, `config`, `dev`, `icons`, `html`, `manifest`, `netlify`, `statics` and `buildInfo`, so a site that wants its own composition can pick the pieces it needs instead of the whole default plugin array.
|
|
33
|
+
- Updated dependencies [94f6299]
|
|
34
|
+
- Updated dependencies [a96f250]
|
|
35
|
+
- @inkandswitch/patchwork-elements@6.0.1
|
|
36
|
+
- @inkandswitch/patchwork-plugins@1.2.1
|
|
37
|
+
- @inkandswitch/patchwork-filesystem@0.2.6
|
|
38
|
+
|
|
3
39
|
## 0.7.2
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* and the automerge-worker handoff and nothing else.
|
|
19
19
|
*/
|
|
20
20
|
import { Repo } from "@automerge/vanillajs/slim";
|
|
21
|
-
import type { AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
|
|
21
|
+
import type { AutomergeRepoKeyhiveBase as AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
|
|
22
22
|
import type { Patchwork, PatchworkOptions } from "./types.js";
|
|
23
23
|
declare global {
|
|
24
24
|
interface Window {
|
package/dist/index.js
CHANGED
|
@@ -94,7 +94,11 @@ async function doSetup(options) {
|
|
|
94
94
|
// Mirror the boot wiring: a keyhive repo talks to the worker through a
|
|
95
95
|
// keyhive adapter wrapped around the message channel.
|
|
96
96
|
const registered = bootHive
|
|
97
|
-
? bootHive.createKeyhiveNetworkAdapter(fresh,
|
|
97
|
+
? bootHive.createKeyhiveNetworkAdapter(fresh, {
|
|
98
|
+
onlyShareWithSyncServer: false,
|
|
99
|
+
periodicallyRequestSync: false,
|
|
100
|
+
syncRequestInterval: 2000,
|
|
101
|
+
})
|
|
98
102
|
: fresh;
|
|
99
103
|
repo.networkSubsystem.addNetworkAdapter(registered);
|
|
100
104
|
removeAdapterFor(repo, workerAdapter, registered);
|
package/dist/repo.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MessageChannelNetworkAdapter, Repo } from "@automerge/vanillajs/slim";
|
|
2
|
-
import { type
|
|
2
|
+
import { type AutomergeRepoKeyhiveBase } from "@automerge/automerge-repo-keyhive";
|
|
3
3
|
import setupServiceWorker from "@inkandswitch/patchwork-bootloader";
|
|
4
4
|
import type { SignerIdentity } from "./types.js";
|
|
5
5
|
export declare function initWasm(): Promise<void>;
|
|
6
6
|
export declare function createRepo(workerAdapter: MessageChannelNetworkAdapter): Promise<{
|
|
7
7
|
repo: Repo;
|
|
8
|
-
hive?:
|
|
8
|
+
hive?: AutomergeRepoKeyhiveBase;
|
|
9
9
|
signerIdentity?: SignerIdentity;
|
|
10
10
|
}>;
|
|
11
11
|
/**
|
package/dist/repo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { initializeWasm, Repo, } from "@automerge/vanillajs/slim";
|
|
2
2
|
import { IndexedDBWorkerStorageAdapter } from "@automerge/automerge-repo-storage-indexeddb/IndexedDBWorkerStorageAdapter";
|
|
3
|
-
import { initKeyhiveWasm,
|
|
3
|
+
import { initKeyhiveWasm, initializeLegacyAutomergeRepoKeyhive, } from "@automerge/automerge-repo-keyhive";
|
|
4
4
|
// eslint-disable-next-line
|
|
5
5
|
// @ts-ignore — initSync is a wasm-bindgen runtime helper not in the .d.ts
|
|
6
6
|
import { initSync as initSubductionSync } from "@automerge/automerge-subduction/slim";
|
|
@@ -32,14 +32,14 @@ export async function createRepo(workerAdapter) {
|
|
|
32
32
|
if (syncServer.keyhive) {
|
|
33
33
|
log("setting up keyhive");
|
|
34
34
|
initKeyhiveWasm();
|
|
35
|
-
const { hive, repo } = await
|
|
35
|
+
const { hive, repo } = await initializeLegacyAutomergeRepoKeyhive({
|
|
36
36
|
createRepo: (repoConfig) => new Repo(repoConfig),
|
|
37
37
|
storage: new IndexedDBWorkerStorageAdapter(keyhiveStorageName),
|
|
38
38
|
peerIdSuffix: storagePrefix + Math.random().toString(36).slice(2),
|
|
39
39
|
networkAdapter: workerAdapter,
|
|
40
40
|
automaticArchiveIngestion: true,
|
|
41
41
|
cachingMode: "periodic",
|
|
42
|
-
|
|
42
|
+
onlyShareWithSyncServer: false,
|
|
43
43
|
// ARK selects the relay via `syncServer`, defaulting to "subduction".
|
|
44
44
|
syncServer: syncServer.keyhive,
|
|
45
45
|
repo: {
|
package/dist/site-kit/html.js
CHANGED
|
@@ -15,6 +15,10 @@ export function escapeHtml(value) {
|
|
|
15
15
|
export function buildHtml(options) {
|
|
16
16
|
const title = options.title ?? DEFAULT_TITLE;
|
|
17
17
|
const lang = (options.html && options.html.lang) || "en";
|
|
18
|
+
const attributes = Object.entries((options.html && options.html.attributes) || {})
|
|
19
|
+
.filter(([name]) => name !== "lang" && /^[a-z][a-z0-9-]*$/i.test(name))
|
|
20
|
+
.map(([name, value]) => ` ${name}="${escapeHtml(value)}"`)
|
|
21
|
+
.join("");
|
|
18
22
|
const entry = options.entry ?? "/src/main.ts";
|
|
19
23
|
const syncServers = resolveSyncServers(options);
|
|
20
24
|
const head = [
|
|
@@ -61,11 +65,17 @@ export function buildHtml(options) {
|
|
|
61
65
|
if (options.html && options.html.extraHead) {
|
|
62
66
|
head.push(options.html.extraHead);
|
|
63
67
|
}
|
|
68
|
+
const body = [
|
|
69
|
+
`<repo-provider><patchwork-view id="root"></patchwork-view></repo-provider>`,
|
|
70
|
+
`<script type="module" src="${entry}"></script>`,
|
|
71
|
+
];
|
|
72
|
+
if (options.html && options.html.extraBody) {
|
|
73
|
+
body.push(options.html.extraBody);
|
|
74
|
+
}
|
|
64
75
|
return `<!doctype html>
|
|
65
|
-
<html lang="${lang}">
|
|
76
|
+
<html lang="${lang}"${attributes}>
|
|
66
77
|
${head.join("\n")}
|
|
67
|
-
|
|
68
|
-
<script type="module" src="${entry}"></script>
|
|
78
|
+
${body.join("\n")}
|
|
69
79
|
</html>
|
|
70
80
|
`;
|
|
71
81
|
}
|
|
@@ -16,8 +16,16 @@ export interface PatchworkIconsOptions {
|
|
|
16
16
|
}
|
|
17
17
|
export interface PatchworkHtmlOptions {
|
|
18
18
|
lang?: string;
|
|
19
|
-
/** Raw HTML appended
|
|
19
|
+
/** Raw HTML appended after the generated head — e.g. extra <link>/<meta> tags. */
|
|
20
20
|
extraHead?: string;
|
|
21
|
+
/** Raw HTML appended after the app root and entry script. */
|
|
22
|
+
extraBody?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Attributes set on the root `<html>` element. How a site states its own
|
|
25
|
+
* configuration to the packages it loads: a package reads the attribute
|
|
26
|
+
* instead of guessing from load order. `lang` stays its own option.
|
|
27
|
+
*/
|
|
28
|
+
attributes?: Record<string, string>;
|
|
21
29
|
}
|
|
22
30
|
export interface PatchworkNetlifyOptions {
|
|
23
31
|
/** Cache-Control: immutable on /assets/*. Default true. */
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AutomergeUrl, DocHandle, Repo } from "@automerge/vanillajs/slim";
|
|
2
|
-
import type { AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
|
|
2
|
+
import type { AutomergeRepoKeyhiveBase as AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
|
|
3
3
|
import type { ModuleWatcher, HasPatchworkMetadata } from "@inkandswitch/patchwork-filesystem";
|
|
4
4
|
import type { AccountCreator, AccountDoc } from "@inkandswitch/patchwork-plugins";
|
|
5
5
|
import type { ServiceWorkerRepoChannelListener, SyncStateDocMessage } from "@inkandswitch/patchwork-bootloader/types";
|
|
@@ -5,4 +5,4 @@ import type { PatchworkVitePluginOptions } from "./patchwork-plugin.js";
|
|
|
5
5
|
* revision, the version of patchwork that built it, and every `static` source,
|
|
6
6
|
* plus whatever extra fields the site passes as the option value.
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function buildInfo(options?: PatchworkVitePluginOptions): Plugin | null;
|
|
@@ -37,7 +37,7 @@ function describe(directory) {
|
|
|
37
37
|
* revision, the version of patchwork that built it, and every `static` source,
|
|
38
38
|
* plus whatever extra fields the site passes as the option value.
|
|
39
39
|
*/
|
|
40
|
-
export function
|
|
40
|
+
export function buildInfo(options = {}) {
|
|
41
41
|
if (!options.buildInfo)
|
|
42
42
|
return null;
|
|
43
43
|
let root;
|
|
@@ -15,5 +15,5 @@ export declare function buildDefines(options?: PatchworkVitePluginOptions): Reco
|
|
|
15
15
|
* used to hand-write in its own vite.config.ts. Each is switched off
|
|
16
16
|
* individually via the matching `false` option.
|
|
17
17
|
*/
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function config(options?: PatchworkVitePluginOptions): Plugin;
|
|
19
19
|
export { wasm };
|
|
@@ -27,7 +27,7 @@ export function buildDefines(options = {}) {
|
|
|
27
27
|
* used to hand-write in its own vite.config.ts. Each is switched off
|
|
28
28
|
* individually via the matching `false` option.
|
|
29
29
|
*/
|
|
30
|
-
export function
|
|
30
|
+
export function config(options = {}) {
|
|
31
31
|
return {
|
|
32
32
|
name: "@patchwork/config",
|
|
33
33
|
config() {
|
package/dist/vite/dev-plugin.js
CHANGED
|
@@ -53,7 +53,7 @@ function workerContexts(options) {
|
|
|
53
53
|
}
|
|
54
54
|
return contexts;
|
|
55
55
|
}
|
|
56
|
-
export function
|
|
56
|
+
export function dev(options = {}) {
|
|
57
57
|
let serve = false;
|
|
58
58
|
let contexts;
|
|
59
59
|
const wasm = new Map(wasmAssets().map(({ fileName, path }) => [`/${fileName}`, path]));
|
|
@@ -8,4 +8,4 @@ import type { PatchworkVitePluginOptions } from "./patchwork-plugin.js";
|
|
|
8
8
|
* virtual module: `resolveId` claims the one id we care about, `load`
|
|
9
9
|
* returns the generated string — nothing ever touches disk.
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function html(options?: PatchworkVitePluginOptions): Plugin | null;
|
package/dist/vite/html-plugin.js
CHANGED
|
@@ -9,7 +9,7 @@ const GENERATED_PATH = "index.html";
|
|
|
9
9
|
* virtual module: `resolveId` claims the one id we care about, `load`
|
|
10
10
|
* returns the generated string — nothing ever touches disk.
|
|
11
11
|
*/
|
|
12
|
-
export function
|
|
12
|
+
export function html(options = {}) {
|
|
13
13
|
if (options.html === false)
|
|
14
14
|
return null;
|
|
15
15
|
const html = buildHtml(options);
|
package/dist/vite/icons.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
import type { PatchworkVitePluginOptions } from "./patchwork-plugin.js";
|
|
3
3
|
/** Emits the rendered icon PNGs for build, and serves the same buffers for dev. */
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function icons(options?: PatchworkVitePluginOptions): Plugin | null;
|
package/dist/vite/icons.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { getIcons } from "../site-kit/icons.js";
|
|
3
3
|
/** Emits the rendered icon PNGs for build, and serves the same buffers for dev. */
|
|
4
|
-
export function
|
|
4
|
+
export function icons(options = {}) {
|
|
5
5
|
if (!options.icons)
|
|
6
6
|
return null;
|
|
7
7
|
const { source } = options.icons;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { relative } from "node:path";
|
|
2
3
|
/**
|
|
3
4
|
* bootloader owns resolving/emitting its own dependencies (it's the one that
|
|
4
5
|
* actually has automerge/keyhive/codemirror/solid/the other patchwork-*
|
|
@@ -87,11 +88,22 @@ export function importmap(options) {
|
|
|
87
88
|
},
|
|
88
89
|
transformIndexHtml: {
|
|
89
90
|
order: "pre",
|
|
90
|
-
handler(html, context) {
|
|
91
|
+
async handler(html, context) {
|
|
91
92
|
const activeImportmap = structuredClone(importmap);
|
|
92
93
|
if (context.server) {
|
|
94
|
+
// The importmap has to name the same URL the site's own imports get
|
|
95
|
+
// rewritten to, which is the pre-bundled dep. `/@id/<dep>` resolves
|
|
96
|
+
// to the same file but is a second URL, and a module fetched under
|
|
97
|
+
// two URLs is evaluated twice — two solids, two automerges.
|
|
98
|
+
const optimizer = context.server.environments.client.depsOptimizer;
|
|
99
|
+
await optimizer?.init();
|
|
100
|
+
const root = context.server.config.root;
|
|
93
101
|
for (const id of Object.keys(builtins)) {
|
|
94
|
-
|
|
102
|
+
const dependency = devDependencyId(id);
|
|
103
|
+
const optimized = optimizer?.metadata.optimized[dependency];
|
|
104
|
+
activeImportmap.imports[id] = optimized
|
|
105
|
+
? `/${relative(root, optimized.file)}?v=${optimized.browserHash}`
|
|
106
|
+
: `/@id/${dependency}`;
|
|
95
107
|
}
|
|
96
108
|
}
|
|
97
109
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
import type { PatchworkVitePluginOptions } from "./patchwork-plugin.js";
|
|
3
3
|
/** Emits manifest.webmanifest for build and serves it for dev, from the same generated object. */
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function manifest(options?: PatchworkVitePluginOptions): Plugin | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildManifest } from "../site-kit/manifest.js";
|
|
2
2
|
/** Emits manifest.webmanifest for build and serves it for dev, from the same generated object. */
|
|
3
|
-
export function
|
|
3
|
+
export function manifest(options = {}) {
|
|
4
4
|
if (options.manifest === false)
|
|
5
5
|
return null;
|
|
6
6
|
const manifest = buildManifest(options);
|
|
@@ -6,4 +6,4 @@ import type { PatchworkVitePluginOptions } from "./patchwork-plugin.js";
|
|
|
6
6
|
* The Link header shares its sync-server/wasm-asset lists with html-plugin
|
|
7
7
|
* so the two never drift out of sync with each other.
|
|
8
8
|
*/
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function netlify(options?: PatchworkVitePluginOptions): Plugin | null;
|
|
@@ -5,7 +5,7 @@ import { buildHeaders, REDIRECTS } from "../site-kit/netlify.js";
|
|
|
5
5
|
* The Link header shares its sync-server/wasm-asset lists with html-plugin
|
|
6
6
|
* so the two never drift out of sync with each other.
|
|
7
7
|
*/
|
|
8
|
-
export function
|
|
8
|
+
export function netlify(options = {}) {
|
|
9
9
|
if (options.netlify === false)
|
|
10
10
|
return null;
|
|
11
11
|
const headers = buildHeaders(options);
|
|
@@ -23,6 +23,16 @@ import type { PatchworkSiteOptions } from "../site-kit/options.js";
|
|
|
23
23
|
* a different bundler adapter.
|
|
24
24
|
*/
|
|
25
25
|
export default function patchwork(options?: PatchworkVitePluginOptions): Plugin<any>[];
|
|
26
|
+
export { importmap, builtins, devDependencyId } from "./importmap-plugin.js";
|
|
27
|
+
export { serviceworker, workers } from "./service-worker-plugin.js";
|
|
28
|
+
export { config, buildDefines, wasm } from "./config-plugin.js";
|
|
29
|
+
export { dev } from "./dev-plugin.js";
|
|
30
|
+
export { icons } from "./icons.js";
|
|
31
|
+
export { html } from "./html-plugin.js";
|
|
32
|
+
export { manifest } from "./manifest-plugin.js";
|
|
33
|
+
export { netlify } from "./netlify-plugin.js";
|
|
34
|
+
export { statics, resolveStatic } from "./static-plugin.js";
|
|
35
|
+
export { buildInfo } from "./build-info-plugin.js";
|
|
26
36
|
type Imports = {
|
|
27
37
|
[name: string]: string;
|
|
28
38
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { importmap } from "./importmap-plugin.js";
|
|
2
2
|
import { serviceworker } from "./service-worker-plugin.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
3
|
+
import { config, wasm } from "./config-plugin.js";
|
|
4
|
+
import { dev } from "./dev-plugin.js";
|
|
5
|
+
import { icons } from "./icons.js";
|
|
6
|
+
import { html } from "./html-plugin.js";
|
|
7
|
+
import { manifest } from "./manifest-plugin.js";
|
|
8
|
+
import { netlify } from "./netlify-plugin.js";
|
|
9
|
+
import { statics } from "./static-plugin.js";
|
|
10
|
+
import { buildInfo } from "./build-info-plugin.js";
|
|
11
11
|
/**
|
|
12
12
|
* The patchwork vite plugin. A site's vite.config.ts can shrink down to
|
|
13
13
|
* `plugins: [patchwork({...})]` plus a single source icon file — this plugin
|
|
@@ -32,15 +32,25 @@ import { buildInfoPlugin } from "./build-info-plugin.js";
|
|
|
32
32
|
export default function patchwork(options) {
|
|
33
33
|
return [
|
|
34
34
|
wasm(),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
config(options),
|
|
36
|
+
icons(options),
|
|
37
|
+
html(options),
|
|
38
|
+
manifest(options),
|
|
39
|
+
netlify(options),
|
|
40
40
|
importmap(options),
|
|
41
41
|
serviceworker(),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
dev(options),
|
|
43
|
+
statics(options),
|
|
44
|
+
buildInfo(options),
|
|
45
45
|
].filter((plugin) => plugin != null);
|
|
46
46
|
}
|
|
47
|
+
export { importmap, builtins, devDependencyId } from "./importmap-plugin.js";
|
|
48
|
+
export { serviceworker, workers } from "./service-worker-plugin.js";
|
|
49
|
+
export { config, buildDefines, wasm } from "./config-plugin.js";
|
|
50
|
+
export { dev } from "./dev-plugin.js";
|
|
51
|
+
export { icons } from "./icons.js";
|
|
52
|
+
export { html } from "./html-plugin.js";
|
|
53
|
+
export { manifest } from "./manifest-plugin.js";
|
|
54
|
+
export { netlify } from "./netlify-plugin.js";
|
|
55
|
+
export { statics, resolveStatic } from "./static-plugin.js";
|
|
56
|
+
export { buildInfo } from "./build-info-plugin.js";
|
|
@@ -44,4 +44,4 @@ export declare function resolveStatic(options: PatchworkVitePluginOptions, root:
|
|
|
44
44
|
* order, and a site keeps its own `modules.json` by listing it before the
|
|
45
45
|
* package it borrows the rest of the packages from.
|
|
46
46
|
*/
|
|
47
|
-
export declare function
|
|
47
|
+
export declare function statics(options?: PatchworkVitePluginOptions): Plugin | null;
|
|
@@ -116,7 +116,7 @@ async function files(source, directory = source) {
|
|
|
116
116
|
* order, and a site keeps its own `modules.json` by listing it before the
|
|
117
117
|
* package it borrows the rest of the packages from.
|
|
118
118
|
*/
|
|
119
|
-
export function
|
|
119
|
+
export function statics(options = {}) {
|
|
120
120
|
if (!options.static?.length)
|
|
121
121
|
return null;
|
|
122
122
|
let sources = [];
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "git+https://github.com/inkandswitch/patchwork-system.git",
|
|
6
6
|
"directory": "core/patchwork"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.7.
|
|
8
|
+
"version": "0.7.4",
|
|
9
9
|
"author": "Ink & Switch",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"license": "MIT",
|
|
@@ -19,6 +19,46 @@
|
|
|
19
19
|
"import": "./dist/vite/patchwork-plugin.js",
|
|
20
20
|
"types": "./dist/vite/patchwork-plugin.d.ts"
|
|
21
21
|
},
|
|
22
|
+
"./vite/build-info": {
|
|
23
|
+
"import": "./dist/vite/build-info-plugin.js",
|
|
24
|
+
"types": "./dist/vite/build-info-plugin.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./vite/config": {
|
|
27
|
+
"import": "./dist/vite/config-plugin.js",
|
|
28
|
+
"types": "./dist/vite/config-plugin.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./vite/dev": {
|
|
31
|
+
"import": "./dist/vite/dev-plugin.js",
|
|
32
|
+
"types": "./dist/vite/dev-plugin.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./vite/html": {
|
|
35
|
+
"import": "./dist/vite/html-plugin.js",
|
|
36
|
+
"types": "./dist/vite/html-plugin.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"./vite/icons": {
|
|
39
|
+
"import": "./dist/vite/icons.js",
|
|
40
|
+
"types": "./dist/vite/icons.d.ts"
|
|
41
|
+
},
|
|
42
|
+
"./vite/importmap": {
|
|
43
|
+
"import": "./dist/vite/importmap-plugin.js",
|
|
44
|
+
"types": "./dist/vite/importmap-plugin.d.ts"
|
|
45
|
+
},
|
|
46
|
+
"./vite/manifest": {
|
|
47
|
+
"import": "./dist/vite/manifest-plugin.js",
|
|
48
|
+
"types": "./dist/vite/manifest-plugin.d.ts"
|
|
49
|
+
},
|
|
50
|
+
"./vite/netlify": {
|
|
51
|
+
"import": "./dist/vite/netlify-plugin.js",
|
|
52
|
+
"types": "./dist/vite/netlify-plugin.d.ts"
|
|
53
|
+
},
|
|
54
|
+
"./vite/service-worker": {
|
|
55
|
+
"import": "./dist/vite/service-worker-plugin.js",
|
|
56
|
+
"types": "./dist/vite/service-worker-plugin.d.ts"
|
|
57
|
+
},
|
|
58
|
+
"./vite/static": {
|
|
59
|
+
"import": "./dist/vite/static-plugin.js",
|
|
60
|
+
"types": "./dist/vite/static-plugin.d.ts"
|
|
61
|
+
},
|
|
22
62
|
"./head": {
|
|
23
63
|
"import": "./dist/head.js"
|
|
24
64
|
},
|
|
@@ -33,21 +73,21 @@
|
|
|
33
73
|
},
|
|
34
74
|
"dependencies": {
|
|
35
75
|
"@automerge/automerge": "3.3.2",
|
|
36
|
-
"@automerge/automerge-repo": "2.6.0-subduction.
|
|
37
|
-
"@automerge/automerge-repo-keyhive": "0.
|
|
38
|
-
"@automerge/automerge-repo-storage-indexeddb": "2.6.0-subduction.
|
|
76
|
+
"@automerge/automerge-repo": "2.6.0-subduction.48",
|
|
77
|
+
"@automerge/automerge-repo-keyhive": "0.5.0-alpha.7",
|
|
78
|
+
"@automerge/automerge-repo-storage-indexeddb": "2.6.0-subduction.48",
|
|
39
79
|
"@automerge/automerge-subduction": "0.16.1",
|
|
40
|
-
"@automerge/vanillajs": "2.6.0-subduction.
|
|
80
|
+
"@automerge/vanillajs": "2.6.0-subduction.48",
|
|
41
81
|
"@types/debug": "^4.1.13",
|
|
42
82
|
"debug": "^4.4.3",
|
|
43
83
|
"esbuild": "^0.23.1",
|
|
44
84
|
"sharp": "^0.35.3",
|
|
45
85
|
"vite-plugin-wasm": "^3.6.0",
|
|
46
|
-
"@inkandswitch/patchwork-bootloader": "^0.6.
|
|
47
|
-
"@inkandswitch/patchwork-elements": "^6.0.
|
|
48
|
-
"@inkandswitch/patchwork-filesystem": "^0.2.
|
|
49
|
-
"@inkandswitch/patchwork-
|
|
50
|
-
"@inkandswitch/patchwork-
|
|
86
|
+
"@inkandswitch/patchwork-bootloader": "^0.6.3",
|
|
87
|
+
"@inkandswitch/patchwork-elements": "^6.0.2",
|
|
88
|
+
"@inkandswitch/patchwork-filesystem": "^0.2.8",
|
|
89
|
+
"@inkandswitch/patchwork-plugins": "^1.2.3",
|
|
90
|
+
"@inkandswitch/patchwork-providers": "^0.5.2"
|
|
51
91
|
},
|
|
52
92
|
"devDependencies": {
|
|
53
93
|
"rollup": "^4.61.1",
|
package/src/index.ts
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "@automerge/vanillajs/slim";
|
|
26
26
|
import * as Automerge from "@automerge/automerge/slim";
|
|
27
27
|
import * as AutomergeRepo from "@automerge/automerge-repo/slim";
|
|
28
|
-
import type { AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
|
|
28
|
+
import type { AutomergeRepoKeyhiveBase as AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
|
|
29
29
|
|
|
30
30
|
import { ModuleWatcher } from "@inkandswitch/patchwork-filesystem";
|
|
31
31
|
import { importAutomergePackageViaWorker } from "@inkandswitch/patchwork-bootloader/module-loader";
|
|
@@ -97,9 +97,7 @@ export function setup(options: PatchworkOptions = {}): Promise<Patchwork> {
|
|
|
97
97
|
timer = setTimeout(
|
|
98
98
|
() =>
|
|
99
99
|
reject(
|
|
100
|
-
new Error(
|
|
101
|
-
`patchwork.setup: boot did not finish within ${timeout}ms`
|
|
102
|
-
)
|
|
100
|
+
new Error(`patchwork.setup: boot did not finish within ${timeout}ms`)
|
|
103
101
|
),
|
|
104
102
|
timeout
|
|
105
103
|
);
|
|
@@ -161,7 +159,11 @@ async function doSetup(options: PatchworkOptions): Promise<Patchwork> {
|
|
|
161
159
|
// Mirror the boot wiring: a keyhive repo talks to the worker through a
|
|
162
160
|
// keyhive adapter wrapped around the message channel.
|
|
163
161
|
const registered = bootHive
|
|
164
|
-
? bootHive.createKeyhiveNetworkAdapter(fresh,
|
|
162
|
+
? bootHive.createKeyhiveNetworkAdapter(fresh, {
|
|
163
|
+
onlyShareWithSyncServer: false,
|
|
164
|
+
periodicallyRequestSync: false,
|
|
165
|
+
syncRequestInterval: 2000,
|
|
166
|
+
})
|
|
165
167
|
: fresh;
|
|
166
168
|
repo.networkSubsystem.addNetworkAdapter(registered as any);
|
|
167
169
|
removeAdapterFor(repo, workerAdapter, registered);
|
|
@@ -264,9 +266,8 @@ async function doSetup(options: PatchworkOptions): Promise<Patchwork> {
|
|
|
264
266
|
},
|
|
265
267
|
|
|
266
268
|
async create<D>(type: string, init?: (doc: D) => void) {
|
|
267
|
-
const datatype =
|
|
268
|
-
"patchwork:datatype"
|
|
269
|
-
).load(type);
|
|
269
|
+
const datatype =
|
|
270
|
+
await getRegistry<DatatypeDescription>("patchwork:datatype").load(type);
|
|
270
271
|
if (!datatype) {
|
|
271
272
|
throw new Error(
|
|
272
273
|
`patchwork.create: no datatype registered for "${type}"`
|
package/src/repo.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { IndexedDBWorkerStorageAdapter } from "@automerge/automerge-repo-storage
|
|
|
8
8
|
import * as AutomergeRepo from "@automerge/automerge-repo/slim";
|
|
9
9
|
import {
|
|
10
10
|
initKeyhiveWasm,
|
|
11
|
-
|
|
12
|
-
type
|
|
11
|
+
initializeLegacyAutomergeRepoKeyhive,
|
|
12
|
+
type AutomergeRepoKeyhiveBase,
|
|
13
13
|
type SyncServerSelection,
|
|
14
14
|
} from "@automerge/automerge-repo-keyhive";
|
|
15
15
|
// eslint-disable-next-line
|
|
@@ -57,20 +57,20 @@ export async function createRepo(
|
|
|
57
57
|
workerAdapter: MessageChannelNetworkAdapter
|
|
58
58
|
): Promise<{
|
|
59
59
|
repo: Repo;
|
|
60
|
-
hive?:
|
|
60
|
+
hive?: AutomergeRepoKeyhiveBase;
|
|
61
61
|
signerIdentity?: SignerIdentity;
|
|
62
62
|
}> {
|
|
63
63
|
if (syncServer.keyhive) {
|
|
64
64
|
log("setting up keyhive");
|
|
65
65
|
initKeyhiveWasm();
|
|
66
|
-
const { hive, repo } = await
|
|
66
|
+
const { hive, repo } = await initializeLegacyAutomergeRepoKeyhive({
|
|
67
67
|
createRepo: (repoConfig) => new Repo(repoConfig),
|
|
68
68
|
storage: new IndexedDBWorkerStorageAdapter(keyhiveStorageName),
|
|
69
69
|
peerIdSuffix: storagePrefix + Math.random().toString(36).slice(2),
|
|
70
70
|
networkAdapter: workerAdapter,
|
|
71
71
|
automaticArchiveIngestion: true,
|
|
72
72
|
cachingMode: "periodic",
|
|
73
|
-
|
|
73
|
+
onlyShareWithSyncServer: false,
|
|
74
74
|
// ARK selects the relay via `syncServer`, defaulting to "subduction".
|
|
75
75
|
syncServer: syncServer.keyhive,
|
|
76
76
|
repo: {
|
package/src/site-kit/html.ts
CHANGED
|
@@ -18,6 +18,12 @@ export function escapeHtml(value: string): string {
|
|
|
18
18
|
export function buildHtml(options: PatchworkSiteOptions): string {
|
|
19
19
|
const title = options.title ?? DEFAULT_TITLE;
|
|
20
20
|
const lang = (options.html && options.html.lang) || "en";
|
|
21
|
+
const attributes = Object.entries(
|
|
22
|
+
(options.html && options.html.attributes) || {}
|
|
23
|
+
)
|
|
24
|
+
.filter(([name]) => name !== "lang" && /^[a-z][a-z0-9-]*$/i.test(name))
|
|
25
|
+
.map(([name, value]) => ` ${name}="${escapeHtml(value)}"`)
|
|
26
|
+
.join("");
|
|
21
27
|
const entry = options.entry ?? "/src/main.ts";
|
|
22
28
|
const syncServers = resolveSyncServers(options);
|
|
23
29
|
|
|
@@ -90,11 +96,19 @@ export function buildHtml(options: PatchworkSiteOptions): string {
|
|
|
90
96
|
head.push(options.html.extraHead);
|
|
91
97
|
}
|
|
92
98
|
|
|
99
|
+
const body = [
|
|
100
|
+
`<repo-provider><patchwork-view id="root"></patchwork-view></repo-provider>`,
|
|
101
|
+
`<script type="module" src="${entry}"></script>`,
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
if (options.html && options.html.extraBody) {
|
|
105
|
+
body.push(options.html.extraBody);
|
|
106
|
+
}
|
|
107
|
+
|
|
93
108
|
return `<!doctype html>
|
|
94
|
-
<html lang="${lang}">
|
|
109
|
+
<html lang="${lang}"${attributes}>
|
|
95
110
|
${head.join("\n")}
|
|
96
|
-
|
|
97
|
-
<script type="module" src="${entry}"></script>
|
|
111
|
+
${body.join("\n")}
|
|
98
112
|
</html>
|
|
99
113
|
`;
|
|
100
114
|
}
|
package/src/site-kit/options.ts
CHANGED
|
@@ -19,8 +19,16 @@ export interface PatchworkIconsOptions {
|
|
|
19
19
|
|
|
20
20
|
export interface PatchworkHtmlOptions {
|
|
21
21
|
lang?: string;
|
|
22
|
-
/** Raw HTML appended
|
|
22
|
+
/** Raw HTML appended after the generated head — e.g. extra <link>/<meta> tags. */
|
|
23
23
|
extraHead?: string;
|
|
24
|
+
/** Raw HTML appended after the app root and entry script. */
|
|
25
|
+
extraBody?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Attributes set on the root `<html>` element. How a site states its own
|
|
28
|
+
* configuration to the packages it loads: a package reads the attribute
|
|
29
|
+
* instead of guessing from load order. `lang` stays its own option.
|
|
30
|
+
*/
|
|
31
|
+
attributes?: Record<string, string>;
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
export interface PatchworkNetlifyOptions {
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AutomergeUrl, DocHandle, Repo } from "@automerge/vanillajs/slim";
|
|
2
|
-
import type { AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
|
|
2
|
+
import type { AutomergeRepoKeyhiveBase as AutomergeRepoKeyhive } from "@automerge/automerge-repo-keyhive";
|
|
3
3
|
import type {
|
|
4
4
|
ModuleWatcher,
|
|
5
5
|
HasPatchworkMetadata,
|
|
@@ -43,7 +43,7 @@ function describe(directory: string) {
|
|
|
43
43
|
* revision, the version of patchwork that built it, and every `static` source,
|
|
44
44
|
* plus whatever extra fields the site passes as the option value.
|
|
45
45
|
*/
|
|
46
|
-
export function
|
|
46
|
+
export function buildInfo(
|
|
47
47
|
options: PatchworkVitePluginOptions = {}
|
|
48
48
|
): Plugin | null {
|
|
49
49
|
if (!options.buildInfo) return null;
|
|
@@ -40,7 +40,7 @@ export function buildDefines(
|
|
|
40
40
|
* used to hand-write in its own vite.config.ts. Each is switched off
|
|
41
41
|
* individually via the matching `false` option.
|
|
42
42
|
*/
|
|
43
|
-
export function
|
|
43
|
+
export function config(
|
|
44
44
|
options: PatchworkVitePluginOptions = {}
|
|
45
45
|
): Plugin {
|
|
46
46
|
return {
|
package/src/vite/dev-plugin.ts
CHANGED
|
@@ -71,7 +71,7 @@ function workerContexts(
|
|
|
71
71
|
return contexts;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export function
|
|
74
|
+
export function dev(options: PatchworkVitePluginOptions = {}): Plugin {
|
|
75
75
|
let serve = false;
|
|
76
76
|
let contexts: Map<string, Promise<esbuild.BuildContext>> | undefined;
|
|
77
77
|
const wasm = new Map(
|
package/src/vite/html-plugin.ts
CHANGED
|
@@ -13,7 +13,7 @@ const GENERATED_PATH = "index.html";
|
|
|
13
13
|
* virtual module: `resolveId` claims the one id we care about, `load`
|
|
14
14
|
* returns the generated string — nothing ever touches disk.
|
|
15
15
|
*/
|
|
16
|
-
export function
|
|
16
|
+
export function html(
|
|
17
17
|
options: PatchworkVitePluginOptions = {}
|
|
18
18
|
): Plugin | null {
|
|
19
19
|
if (options.html === false) return null;
|
package/src/vite/icons.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { PatchworkVitePluginOptions } from "./patchwork-plugin.js";
|
|
|
4
4
|
import { getIcons } from "../site-kit/icons.js";
|
|
5
5
|
|
|
6
6
|
/** Emits the rendered icon PNGs for build, and serves the same buffers for dev. */
|
|
7
|
-
export function
|
|
7
|
+
export function icons(
|
|
8
8
|
options: PatchworkVitePluginOptions = {}
|
|
9
9
|
): Plugin | null {
|
|
10
10
|
if (!options.icons) return null;
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
PatchworkVitePluginOptions,
|
|
5
5
|
} from "./patchwork-plugin.js";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { relative } from "node:path";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* bootloader owns resolving/emitting its own dependencies (it's the one that
|
|
@@ -115,11 +116,22 @@ export function importmap(options?: PatchworkVitePluginOptions): Plugin {
|
|
|
115
116
|
},
|
|
116
117
|
transformIndexHtml: {
|
|
117
118
|
order: "pre",
|
|
118
|
-
handler(html, context) {
|
|
119
|
+
async handler(html, context) {
|
|
119
120
|
const activeImportmap = structuredClone(importmap);
|
|
120
121
|
if (context.server) {
|
|
122
|
+
// The importmap has to name the same URL the site's own imports get
|
|
123
|
+
// rewritten to, which is the pre-bundled dep. `/@id/<dep>` resolves
|
|
124
|
+
// to the same file but is a second URL, and a module fetched under
|
|
125
|
+
// two URLs is evaluated twice — two solids, two automerges.
|
|
126
|
+
const optimizer = context.server.environments.client.depsOptimizer;
|
|
127
|
+
await optimizer?.init();
|
|
128
|
+
const root = context.server.config.root;
|
|
121
129
|
for (const id of Object.keys(builtins)) {
|
|
122
|
-
|
|
130
|
+
const dependency = devDependencyId(id);
|
|
131
|
+
const optimized = optimizer?.metadata.optimized[dependency];
|
|
132
|
+
activeImportmap.imports[id] = optimized
|
|
133
|
+
? `/${relative(root, optimized.file)}?v=${optimized.browserHash}`
|
|
134
|
+
: `/@id/${dependency}`;
|
|
123
135
|
}
|
|
124
136
|
}
|
|
125
137
|
return {
|
|
@@ -3,7 +3,7 @@ import type { PatchworkVitePluginOptions } from "./patchwork-plugin.js";
|
|
|
3
3
|
import { buildManifest } from "../site-kit/manifest.js";
|
|
4
4
|
|
|
5
5
|
/** Emits manifest.webmanifest for build and serves it for dev, from the same generated object. */
|
|
6
|
-
export function
|
|
6
|
+
export function manifest(
|
|
7
7
|
options: PatchworkVitePluginOptions = {}
|
|
8
8
|
): Plugin | null {
|
|
9
9
|
if (options.manifest === false) return null;
|
|
@@ -8,7 +8,7 @@ import { buildHeaders, REDIRECTS } from "../site-kit/netlify.js";
|
|
|
8
8
|
* The Link header shares its sync-server/wasm-asset lists with html-plugin
|
|
9
9
|
* so the two never drift out of sync with each other.
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function netlify(
|
|
12
12
|
options: PatchworkVitePluginOptions = {}
|
|
13
13
|
): Plugin | null {
|
|
14
14
|
if (options.netlify === false) return null;
|
|
@@ -2,14 +2,14 @@ import type { Plugin, ServerOptions, PreviewOptions, BuildOptions } from "vite";
|
|
|
2
2
|
|
|
3
3
|
import { importmap } from "./importmap-plugin.js";
|
|
4
4
|
import { serviceworker } from "./service-worker-plugin.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
5
|
+
import { config, wasm } from "./config-plugin.js";
|
|
6
|
+
import { dev } from "./dev-plugin.js";
|
|
7
|
+
import { icons } from "./icons.js";
|
|
8
|
+
import { html } from "./html-plugin.js";
|
|
9
|
+
import { manifest } from "./manifest-plugin.js";
|
|
10
|
+
import { netlify } from "./netlify-plugin.js";
|
|
11
|
+
import { statics, type PatchworkStaticSource } from "./static-plugin.js";
|
|
12
|
+
import { buildInfo } from "./build-info-plugin.js";
|
|
13
13
|
import type { PatchworkSiteOptions } from "../site-kit/options.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -36,19 +36,30 @@ import type { PatchworkSiteOptions } from "../site-kit/options.js";
|
|
|
36
36
|
export default function patchwork(options?: PatchworkVitePluginOptions) {
|
|
37
37
|
return [
|
|
38
38
|
wasm(),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
config(options),
|
|
40
|
+
icons(options),
|
|
41
|
+
html(options),
|
|
42
|
+
manifest(options),
|
|
43
|
+
netlify(options),
|
|
44
44
|
importmap(options),
|
|
45
45
|
serviceworker(),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
dev(options),
|
|
47
|
+
statics(options),
|
|
48
|
+
buildInfo(options),
|
|
49
49
|
].filter((plugin): plugin is Plugin => plugin != null);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
export { importmap, builtins, devDependencyId } from "./importmap-plugin.js";
|
|
53
|
+
export { serviceworker, workers } from "./service-worker-plugin.js";
|
|
54
|
+
export { config, buildDefines, wasm } from "./config-plugin.js";
|
|
55
|
+
export { dev } from "./dev-plugin.js";
|
|
56
|
+
export { icons } from "./icons.js";
|
|
57
|
+
export { html } from "./html-plugin.js";
|
|
58
|
+
export { manifest } from "./manifest-plugin.js";
|
|
59
|
+
export { netlify } from "./netlify-plugin.js";
|
|
60
|
+
export { statics, resolveStatic } from "./static-plugin.js";
|
|
61
|
+
export { buildInfo } from "./build-info-plugin.js";
|
|
62
|
+
|
|
52
63
|
type Imports = { [name: string]: string };
|
|
53
64
|
export type ImportMap = {
|
|
54
65
|
imports: Imports;
|
|
@@ -177,7 +177,7 @@ async function files(source: string, directory = source): Promise<string[]> {
|
|
|
177
177
|
* order, and a site keeps its own `modules.json` by listing it before the
|
|
178
178
|
* package it borrows the rest of the packages from.
|
|
179
179
|
*/
|
|
180
|
-
export function
|
|
180
|
+
export function statics(
|
|
181
181
|
options: PatchworkVitePluginOptions = {}
|
|
182
182
|
): Plugin | null {
|
|
183
183
|
if (!options.static?.length) return null;
|