astro-integration-pocketbase 2.1.0 → 2.1.1-next.1
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 +10 -14
- package/src/core/refresh-collections-realtime.ts +6 -2
- package/src/middleware/index.ts +2 -1
- package/src/pocketbase-integration.ts +1 -1
- package/src/toolbar/dom/create-entity.ts +1 -1
- package/src/toolbar/dom/create-header.ts +2 -3
- package/src/utils/push-to-map-array.ts +6 -4
- package/src/toolbar/page-navigation-listener.ts +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-integration-pocketbase",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1-next.1",
|
|
4
4
|
"description": "An Astro integration to support developers working with astro-loader-pocketbase.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -33,35 +33,31 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"format": "npx prettier . --write --cache",
|
|
35
35
|
"format:check": "npx prettier . --check --cache",
|
|
36
|
-
"lint": "
|
|
37
|
-
"lint:fix": "
|
|
36
|
+
"lint": "oxlint",
|
|
37
|
+
"lint:fix": "oxlint --fix",
|
|
38
38
|
"prepare": "husky",
|
|
39
39
|
"typecheck": "npx tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@commitlint/cli": "^19.8.1",
|
|
43
43
|
"@commitlint/config-conventional": "^19.8.1",
|
|
44
|
-
"@eslint/js": "^9.30.1",
|
|
45
|
-
"@stylistic/eslint-plugin": "^5.1.0",
|
|
46
44
|
"@types/node": "^22.14.1",
|
|
47
|
-
"astro": "^5.
|
|
48
|
-
"eslint": "^9.30.1",
|
|
49
|
-
"eslint-config-prettier": "^10.1.5",
|
|
45
|
+
"astro": "^5.12.8",
|
|
50
46
|
"eventsource": "^4.0.0",
|
|
51
47
|
"globals": "^16.3.0",
|
|
52
48
|
"husky": "^9.1.7",
|
|
53
|
-
"lint-staged": "^16.1.
|
|
49
|
+
"lint-staged": "^16.1.4",
|
|
50
|
+
"oxlint": "^1.10.0",
|
|
54
51
|
"prettier": "^3.6.2",
|
|
55
|
-
"prettier-plugin-organize-imports": "^4.
|
|
56
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
57
|
-
"typescript": "^5.
|
|
58
|
-
"typescript-eslint": "^8.35.1"
|
|
52
|
+
"prettier-plugin-organize-imports": "^4.2.0",
|
|
53
|
+
"prettier-plugin-packagejson": "^2.5.19",
|
|
54
|
+
"typescript": "^5.9.2"
|
|
59
55
|
},
|
|
60
56
|
"peerDependencies": {
|
|
61
57
|
"astro": "^5.0.0",
|
|
62
58
|
"eventsource": "^4.0.0"
|
|
63
59
|
},
|
|
64
|
-
"packageManager": "npm@11.
|
|
60
|
+
"packageManager": "npm@11.5.2",
|
|
65
61
|
"publishConfig": {
|
|
66
62
|
"access": "public",
|
|
67
63
|
"provenance": true
|
|
@@ -4,6 +4,9 @@ import type { PocketBaseIntegrationOptions } from "../types/pocketbase-integrati
|
|
|
4
4
|
import { getSuperuserToken } from "../utils/get-superuser-token";
|
|
5
5
|
import { mapCollectionsToWatch } from "../utils/map-collections-to-watch";
|
|
6
6
|
|
|
7
|
+
// This function is not as complex as it seems, but uses a lot of shared state
|
|
8
|
+
// that makes it hard to split into smaller functions.
|
|
9
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
7
10
|
export function refreshCollectionsRealtime(
|
|
8
11
|
{
|
|
9
12
|
url,
|
|
@@ -51,7 +54,8 @@ export function refreshCollectionsRealtime(
|
|
|
51
54
|
let isConnected = false;
|
|
52
55
|
|
|
53
56
|
// Log potential errors
|
|
54
|
-
|
|
57
|
+
// oxlint-disable-next-line prefer-await-to-callbacks
|
|
58
|
+
eventSource.addEventListener("error", (error) => {
|
|
55
59
|
isConnected = false;
|
|
56
60
|
|
|
57
61
|
// Wait for 5 seconds in case of a connection error
|
|
@@ -65,7 +69,7 @@ export function refreshCollectionsRealtime(
|
|
|
65
69
|
`Error while connecting to PocketBase realtime API: ${error.type}`
|
|
66
70
|
);
|
|
67
71
|
}, 5000);
|
|
68
|
-
};
|
|
72
|
+
});
|
|
69
73
|
|
|
70
74
|
// Add event listeners for all collections
|
|
71
75
|
for (const collection of remoteCollections) {
|
package/src/middleware/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineMiddleware } from "astro/middleware";
|
|
2
|
-
import {
|
|
2
|
+
import type { PocketBaseEntry } from "./is-pocketbase-entry";
|
|
3
|
+
import { isPocketbaseEntry } from "./is-pocketbase-entry";
|
|
3
4
|
|
|
4
5
|
export const onRequest = defineMiddleware(async (context, next) => {
|
|
5
6
|
// Look for entities given as props to the page
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AstroIntegration } from "astro";
|
|
2
|
-
import { EventSource } from "eventsource";
|
|
2
|
+
import type { EventSource } from "eventsource";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { handleRefreshCollections, refreshCollectionsRealtime } from "./core";
|
|
5
5
|
import type { ToolbarOptions } from "./toolbar/types/options";
|
|
@@ -33,7 +33,7 @@ function createEntity(data: Entity, baseUrl: string): string {
|
|
|
33
33
|
return /* HTML */ `
|
|
34
34
|
<astro-dev-toolbar-card>
|
|
35
35
|
<div class="entity">
|
|
36
|
-
<pre>${JSON.stringify(data,
|
|
36
|
+
<pre>${JSON.stringify(data, undefined, 2).replaceAll("<", "<")}</pre>
|
|
37
37
|
|
|
38
38
|
${baseUrl
|
|
39
39
|
? /* HTML */ `
|
|
@@ -7,6 +7,7 @@ import type { ToolbarOptions } from "../types/options";
|
|
|
7
7
|
/**
|
|
8
8
|
* Creates the header for the PocketBase toolbar.
|
|
9
9
|
*/
|
|
10
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
10
11
|
export function createHeader(
|
|
11
12
|
windowElement: DevToolbarWindow,
|
|
12
13
|
server: ToolbarServerHelpers,
|
|
@@ -114,9 +115,7 @@ export function createHeader(
|
|
|
114
115
|
"astro-integration-pocketbase:real-time",
|
|
115
116
|
realTimeToggle.input.checked
|
|
116
117
|
);
|
|
117
|
-
windowElement
|
|
118
|
-
.querySelector(".toggle-container")
|
|
119
|
-
?.appendChild(realTimeToggle);
|
|
118
|
+
windowElement.querySelector(".toggle-container")?.append(realTimeToggle);
|
|
120
119
|
}
|
|
121
120
|
|
|
122
121
|
if (hasContentLoader) {
|
|
@@ -6,9 +6,11 @@ export function pushToMapArray<TKey, TArray>(
|
|
|
6
6
|
key: TKey,
|
|
7
7
|
value: TArray
|
|
8
8
|
): void {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const array = map.get(key);
|
|
10
|
+
if (array) {
|
|
11
|
+
array.push(value);
|
|
12
|
+
return;
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
map.set(key, [value]);
|
|
14
16
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Execute a callback whenever the user navigates to a new page.
|
|
3
|
-
*/
|
|
4
|
-
export function listenToNavigation(callback: () => void): void {
|
|
5
|
-
// We trigger the callback immediately to ensure the toolbar is in sync with the current page.
|
|
6
|
-
// If no client-side navigation is done, this is the only time the callback will be triggered.
|
|
7
|
-
// Fortunately, this scrip will be re-executed on every page load.
|
|
8
|
-
callback();
|
|
9
|
-
|
|
10
|
-
// If client-side navigation is done (ViewTransitions / ClientRouter), we listen for page-load events.
|
|
11
|
-
document.addEventListener("astro:page-load", () => {
|
|
12
|
-
callback();
|
|
13
|
-
});
|
|
14
|
-
}
|