@almadar/shell-browser 0.1.0 → 1.1.0
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/auth/index.d.ts +1 -1
- package/dist/auth/index.js +4 -4
- package/dist/{chunk-GXG5PI2M.js → chunk-42QF3V52.js} +2 -2
- package/dist/{chunk-DTZ6GAB4.js → chunk-JY6N6LCH.js} +5 -4
- package/dist/index.js +2 -2
- package/dist/kernel-loader.d.ts +29 -0
- package/dist/kernel-loader.js +14 -0
- package/dist/page-facts.js +1 -1
- package/dist/storage/index.js +1 -1
- package/package.json +11 -3
package/dist/auth/index.d.ts
CHANGED
package/dist/auth/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/auth/index.ts
|
|
2
|
-
import { initializeApp, getApps } from "firebase/app";
|
|
2
|
+
import { initializeApp, getApps } from "@firebase/app";
|
|
3
3
|
import {
|
|
4
4
|
GoogleAuthProvider,
|
|
5
5
|
browserLocalPersistence,
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
signInWithPopup,
|
|
18
18
|
signOut,
|
|
19
19
|
updateProfile
|
|
20
|
-
} from "firebase/auth";
|
|
20
|
+
} from "@firebase/auth";
|
|
21
21
|
import { z } from "zod";
|
|
22
|
-
import { JsonValueSchema } from "@almadar/core";
|
|
22
|
+
import { JsonValueSchema, toPayloadValue } from "@almadar/core";
|
|
23
23
|
var ClaimsSchema = z.record(z.string(), JsonValueSchema);
|
|
24
24
|
async function signedIn(user) {
|
|
25
25
|
const { claims } = await user.getIdTokenResult();
|
|
@@ -28,7 +28,7 @@ async function signedIn(user) {
|
|
|
28
28
|
...user.email !== null ? { email: user.email } : {},
|
|
29
29
|
...user.displayName !== null ? { name: user.displayName } : {},
|
|
30
30
|
...user.photoURL !== null ? { photoURL: user.photoURL } : {},
|
|
31
|
-
claims: ClaimsSchema.parse(
|
|
31
|
+
claims: ClaimsSchema.parse(toPayloadValue(claims))
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
function appFor(config) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/storage/IndexedDbPersistence.ts
|
|
2
|
-
import { FULL_WRITE_CAPABILITIES } from "@almadar/core";
|
|
2
|
+
import { FULL_WRITE_CAPABILITIES, mintUlid } from "@almadar/core";
|
|
3
3
|
var CHANGE_LOG = "__changes";
|
|
4
4
|
function request(req) {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
@@ -69,7 +69,7 @@ var IndexedDbPersistence = class _IndexedDbPersistence {
|
|
|
69
69
|
await done(tx);
|
|
70
70
|
}
|
|
71
71
|
async create(entityType, data) {
|
|
72
|
-
const id = typeof data.id === "string" && data.id.length > 0 ? data.id :
|
|
72
|
+
const id = typeof data.id === "string" && data.id.length > 0 ? data.id : mintUlid();
|
|
73
73
|
await this.write(entityType, "create", id, { ...data, id, updatedAt: this.now() });
|
|
74
74
|
return { id };
|
|
75
75
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/page-facts.ts
|
|
2
|
-
var PAGE_FACT_FIELDS = ["hostname", "referrer", "screenWidth"];
|
|
2
|
+
var PAGE_FACT_FIELDS = ["hostname", "referrer", "screenWidth", "href"];
|
|
3
3
|
function parsePageFactFields(value) {
|
|
4
4
|
if (!Array.isArray(value) || value.length === 0) {
|
|
5
|
-
return { error: "browser/page-facts: the fields must be a non-empty list of hostname, referrer, screenWidth" };
|
|
5
|
+
return { error: "browser/page-facts: the fields must be a non-empty list of hostname, referrer, screenWidth, href" };
|
|
6
6
|
}
|
|
7
7
|
const fields = [];
|
|
8
8
|
for (const entry of value) {
|
|
@@ -16,13 +16,14 @@ function parsePageFactFields(value) {
|
|
|
16
16
|
return { fields };
|
|
17
17
|
}
|
|
18
18
|
function readPageFacts(fields) {
|
|
19
|
-
const facts = { available: false, hostname: "", referrer: "", screenWidth: null };
|
|
19
|
+
const facts = { available: false, hostname: "", referrer: "", screenWidth: null, href: "" };
|
|
20
20
|
if (typeof window === "undefined" || typeof document === "undefined") return facts;
|
|
21
21
|
facts.available = true;
|
|
22
22
|
for (const field of fields) {
|
|
23
23
|
if (field === "hostname") facts.hostname = window.location.hostname;
|
|
24
24
|
else if (field === "referrer") facts.referrer = document.referrer;
|
|
25
|
-
else facts.screenWidth = window.screen?.width ?? null;
|
|
25
|
+
else if (field === "screenWidth") facts.screenWidth = window.screen?.width ?? null;
|
|
26
|
+
else facts.href = window.location.href;
|
|
26
27
|
}
|
|
27
28
|
return facts;
|
|
28
29
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CHANGE_LOG,
|
|
3
3
|
IndexedDbPersistence
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-42QF3V52.js";
|
|
5
5
|
import {
|
|
6
6
|
KvWebPort,
|
|
7
7
|
createKvWebPort,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
parsePageFactFields,
|
|
13
13
|
readPageFacts
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-JY6N6LCH.js";
|
|
15
15
|
export {
|
|
16
16
|
CHANGE_LOG,
|
|
17
17
|
IndexedDbPersistence,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one browser loader of the WebAssembly kernel (`@almadar/kernel/client`): where the `.wasm` is served from, and
|
|
3
|
+
* where the language data its operators are routed by comes from. The web template's client and the generated Chrome
|
|
4
|
+
* worker both load the kernel here; what they differ in is only the two locations they pass.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/** The part of the kernel glue module a loader drives. */
|
|
9
|
+
interface BrowserKernelGlue {
|
|
10
|
+
/** Installs the language data (`LanguageBundle` as JSON) for a host with no `node_modules`; the first install wins. */
|
|
11
|
+
installLanguage(bundleJson: string): void;
|
|
12
|
+
}
|
|
13
|
+
interface BrowserKernelSource<Glue extends BrowserKernelGlue> {
|
|
14
|
+
/** The glue module's default export: instantiates the WebAssembly from `module_or_path`. */
|
|
15
|
+
readonly init: (input: {
|
|
16
|
+
module_or_path: string;
|
|
17
|
+
}) => Promise<unknown>;
|
|
18
|
+
/** The glue module namespace (`import * as glue from '@almadar/kernel/client'`). */
|
|
19
|
+
readonly glue: Glue;
|
|
20
|
+
/** Where the `.wasm` is served from. */
|
|
21
|
+
readonly wasm: string;
|
|
22
|
+
/** Where the language bundle is served from: every kernel evaluates through it. */
|
|
23
|
+
readonly language: string;
|
|
24
|
+
}
|
|
25
|
+
/** The kernel module, initialised and with its language installed, once; the language downloads while the wasm instantiates. */
|
|
26
|
+
declare function loadBrowserKernel<Glue extends BrowserKernelGlue>(source: BrowserKernelSource<Glue>): Promise<Glue>;
|
|
27
|
+
|
|
28
|
+
export { loadBrowserKernel };
|
|
29
|
+
export type { BrowserKernelGlue, BrowserKernelSource };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/kernel-loader.ts
|
|
2
|
+
async function fetchLanguage(location) {
|
|
3
|
+
const response = await fetch(location);
|
|
4
|
+
if (!response.ok) throw new Error(`${location}: ${response.status} ${response.statusText}`);
|
|
5
|
+
return response.text();
|
|
6
|
+
}
|
|
7
|
+
async function loadBrowserKernel(source) {
|
|
8
|
+
const [, language] = await Promise.all([source.init({ module_or_path: source.wasm }), fetchLanguage(source.language)]);
|
|
9
|
+
source.glue.installLanguage(language);
|
|
10
|
+
return source.glue;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
loadBrowserKernel
|
|
14
|
+
};
|
package/dist/page-facts.js
CHANGED
package/dist/storage/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almadar/shell-browser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"orbRelease": {
|
|
5
|
+
"severity": "normal"
|
|
6
|
+
},
|
|
4
7
|
"description": "Browser I/O ports for the Almadar TypeScript shell: IndexedDB, page facts and Firebase sign-in SDK.",
|
|
5
8
|
"license": "BUSL-1.1",
|
|
6
9
|
"type": "module",
|
|
@@ -26,6 +29,10 @@
|
|
|
26
29
|
"./page-facts": {
|
|
27
30
|
"types": "./dist/page-facts.d.ts",
|
|
28
31
|
"import": "./dist/page-facts.js"
|
|
32
|
+
},
|
|
33
|
+
"./kernel-loader": {
|
|
34
|
+
"types": "./dist/kernel-loader.d.ts",
|
|
35
|
+
"import": "./dist/kernel-loader.js"
|
|
29
36
|
}
|
|
30
37
|
},
|
|
31
38
|
"files": [
|
|
@@ -33,8 +40,9 @@
|
|
|
33
40
|
],
|
|
34
41
|
"sideEffects": false,
|
|
35
42
|
"dependencies": {
|
|
36
|
-
"@almadar/core": "^
|
|
37
|
-
"firebase": "^
|
|
43
|
+
"@almadar/core": "^11.3.0",
|
|
44
|
+
"@firebase/app": "^0.13.2",
|
|
45
|
+
"@firebase/auth": "^1.10.8",
|
|
38
46
|
"zod": "^4.6.7"
|
|
39
47
|
},
|
|
40
48
|
"devDependencies": {
|