@primate/svelte 0.18.2 → 0.19.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/lib/private/Default.d.ts +17 -0
- package/lib/private/Default.js +20 -0
- package/lib/private/Runtime.d.ts +11 -0
- package/lib/private/Runtime.js +13 -0
- package/lib/private/client/ValidateState.d.ts +8 -0
- package/lib/private/client/ValidateState.js +2 -0
- package/lib/private/client/Validated.d.ts +8 -0
- package/lib/private/client/Validated.js +2 -0
- package/lib/private/client/index.d.ts +11 -0
- package/lib/private/client/index.js +29 -0
- package/lib/private/client/validate.d.ts +25 -0
- package/lib/private/client/validate.js +28 -0
- package/lib/private/context-name.d.ts +3 -0
- package/lib/private/context-name.js +2 -0
- package/lib/private/create-root.d.ts +3 -0
- package/lib/private/create-root.js +49 -0
- package/lib/public/Validated.d.ts +2 -0
- package/lib/public/Validated.js +2 -0
- package/lib/public/browser.d.ts +2 -0
- package/lib/public/browser.js +2 -0
- package/lib/public/context-name.d.ts +2 -0
- package/{src → lib}/public/context-name.js +1 -0
- package/lib/public/default.d.ts +4 -0
- package/lib/public/default.js +3 -0
- package/lib/public/runtime.d.ts +4 -0
- package/lib/public/runtime.js +3 -0
- package/lib/public/validate.d.ts +2 -0
- package/lib/public/validate.js +2 -0
- package/package.json +25 -41
- package/src/private/build/client.js +0 -8
- package/src/private/build/index.js +0 -14
- package/src/private/build/publish.js +0 -40
- package/src/private/build/server.js +0 -6
- package/src/private/client/create-root.js +0 -31
- package/src/private/client/expose.js +0 -1
- package/src/private/client/index.js +0 -18
- package/src/private/client/spa.js +0 -19
- package/src/private/context-name.js +0 -1
- package/src/private/extension.js +0 -1
- package/src/private/i18n/index.js +0 -10
- package/src/private/i18n/locale.js +0 -19
- package/src/private/name.js +0 -1
- package/src/private/pkgname.js +0 -1
- package/src/private/serve/index.js +0 -16
- package/src/private/serve/render.js +0 -4
- package/src/public/default.js +0 -14
- package/src/public/i18n.js +0 -1
- package/src/public/locale.js +0 -1
- package/src/public/runtime.js +0 -12
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Runtime from "#Runtime";
|
|
2
|
+
export default class Default extends Runtime {
|
|
3
|
+
root: {
|
|
4
|
+
create: (depth: number, i18n_active: boolean) => string;
|
|
5
|
+
};
|
|
6
|
+
css: {
|
|
7
|
+
filter: RegExp;
|
|
8
|
+
};
|
|
9
|
+
compile: {
|
|
10
|
+
client: (text: string) => {
|
|
11
|
+
css: string;
|
|
12
|
+
js: string;
|
|
13
|
+
};
|
|
14
|
+
server: (text: string) => string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=Default.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import create_root from "#create-root";
|
|
2
|
+
import Runtime from "#Runtime";
|
|
3
|
+
import { compile } from "svelte/compiler";
|
|
4
|
+
export default class Default extends Runtime {
|
|
5
|
+
root = {
|
|
6
|
+
create: create_root,
|
|
7
|
+
};
|
|
8
|
+
css = {
|
|
9
|
+
filter: /\.sveltecss$/,
|
|
10
|
+
};
|
|
11
|
+
compile = {
|
|
12
|
+
client: (text) => {
|
|
13
|
+
const accessors = true;
|
|
14
|
+
const { css, js } = compile(text, { accessors, generate: "client" });
|
|
15
|
+
return { css: css?.code ?? "", js: js.code };
|
|
16
|
+
},
|
|
17
|
+
server: (text) => compile(text, { generate: "server" }).js.code,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Default.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import FrontendModule from "@primate/core/frontend/Module";
|
|
2
|
+
import type Render from "@primate/core/frontend/Render";
|
|
3
|
+
import type { Component } from "svelte";
|
|
4
|
+
export default class Runtime extends FrontendModule<Component> {
|
|
5
|
+
name: string;
|
|
6
|
+
defaultExtensions: string[];
|
|
7
|
+
layouts: boolean;
|
|
8
|
+
client: boolean;
|
|
9
|
+
render: Render<Component>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=Runtime.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import FrontendModule from "@primate/core/frontend/Module";
|
|
2
|
+
import { render } from "svelte/server";
|
|
3
|
+
export default class Runtime extends FrontendModule {
|
|
4
|
+
name = "svelte";
|
|
5
|
+
defaultExtensions = [".svelte"];
|
|
6
|
+
layouts = true;
|
|
7
|
+
client = true;
|
|
8
|
+
render = (component, props) => {
|
|
9
|
+
const { head, html } = render(component, { props: { p: { ...props } } });
|
|
10
|
+
return { body: html, head };
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=Runtime.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type ValidateState from "#client/ValidateState";
|
|
2
|
+
import type ValidateUpdater from "@primate/core/client/ValidateUpdater";
|
|
3
|
+
import type { Readable } from "svelte/store";
|
|
4
|
+
type Validated<T> = {
|
|
5
|
+
update: (updater: ValidateUpdater<T>) => Promise<void>;
|
|
6
|
+
} & Readable<ValidateState<T>>;
|
|
7
|
+
export type { Validated as default };
|
|
8
|
+
//# sourceMappingURL=Validated.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type ClientData from "@primate/core/client/Data";
|
|
2
|
+
import type Dict from "@rcompat/type/Dict";
|
|
3
|
+
type Data = ClientData<{
|
|
4
|
+
components: string[];
|
|
5
|
+
props: Dict[];
|
|
6
|
+
}>;
|
|
7
|
+
export default class SvelteClient {
|
|
8
|
+
static mount(_component: string, data: ClientData<Data>): void;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import spa from "@primate/core/client/spa";
|
|
2
|
+
import { hydrate, mount } from "svelte";
|
|
3
|
+
// @ts-expect-error esbuild vfs
|
|
4
|
+
import * as components from "svelte:components";
|
|
5
|
+
// @ts-expect-error esbuild vfs
|
|
6
|
+
import root from "svelte:root";
|
|
7
|
+
const make_props = (data) => ({
|
|
8
|
+
components: data.components.map(name => components[name]),
|
|
9
|
+
props: data.props,
|
|
10
|
+
request: {
|
|
11
|
+
...data.request,
|
|
12
|
+
url: new URL(location.href),
|
|
13
|
+
},
|
|
14
|
+
update: () => undefined,
|
|
15
|
+
});
|
|
16
|
+
export default class SvelteClient {
|
|
17
|
+
static mount(_component, data) {
|
|
18
|
+
const _root = (data.ssr ? hydrate : mount)(root, {
|
|
19
|
+
props: {
|
|
20
|
+
p: make_props(data),
|
|
21
|
+
},
|
|
22
|
+
target: document.body,
|
|
23
|
+
});
|
|
24
|
+
data.spa && window.addEventListener("DOMContentLoaded", () => spa((_data, update) => {
|
|
25
|
+
_root.p = { ...make_props(_data), update };
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type Validated from "#client/Validated";
|
|
2
|
+
declare const _default: <T>(initial: T) => {
|
|
3
|
+
delete: (url: string, options?: {
|
|
4
|
+
headers?: import("@rcompat/type/Dict").default<string>;
|
|
5
|
+
map?: ((v: T) => import("@rcompat/type/JSONValue").default) | undefined;
|
|
6
|
+
path?: import("@rcompat/type/JSONPointer").default;
|
|
7
|
+
} | undefined) => Validated<T>;
|
|
8
|
+
patch: (url: string, options?: {
|
|
9
|
+
headers?: import("@rcompat/type/Dict").default<string>;
|
|
10
|
+
map?: ((v: T) => import("@rcompat/type/JSONValue").default) | undefined;
|
|
11
|
+
path?: import("@rcompat/type/JSONPointer").default;
|
|
12
|
+
} | undefined) => Validated<T>;
|
|
13
|
+
post: (url: string, options?: {
|
|
14
|
+
headers?: import("@rcompat/type/Dict").default<string>;
|
|
15
|
+
map?: ((v: T) => import("@rcompat/type/JSONValue").default) | undefined;
|
|
16
|
+
path?: import("@rcompat/type/JSONPointer").default;
|
|
17
|
+
} | undefined) => Validated<T>;
|
|
18
|
+
put: (url: string, options?: {
|
|
19
|
+
headers?: import("@rcompat/type/Dict").default<string>;
|
|
20
|
+
map?: ((v: T) => import("@rcompat/type/JSONValue").default) | undefined;
|
|
21
|
+
path?: import("@rcompat/type/JSONPointer").default;
|
|
22
|
+
} | undefined) => Validated<T>;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
25
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import toValidated from "@primate/core/client/toValidated";
|
|
2
|
+
import validate from "@primate/core/client/validate";
|
|
3
|
+
import { get, writable } from "svelte/store";
|
|
4
|
+
function useValidate(init) {
|
|
5
|
+
const { set, subscribe, update } = writable({
|
|
6
|
+
error: null,
|
|
7
|
+
loading: false,
|
|
8
|
+
value: init.initial,
|
|
9
|
+
});
|
|
10
|
+
async function $update(updater) {
|
|
11
|
+
let previous;
|
|
12
|
+
update((s) => {
|
|
13
|
+
previous = s.value;
|
|
14
|
+
return { ...s, error: null, loading: true, value: updater(s.value) };
|
|
15
|
+
});
|
|
16
|
+
try {
|
|
17
|
+
await validate(init, get({ subscribe }).value);
|
|
18
|
+
update(s => ({ ...s, loading: false }));
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
// rollback
|
|
22
|
+
set({ error: e, loading: false, value: previous });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return { subscribe, update: $update };
|
|
26
|
+
}
|
|
27
|
+
export default toValidated(useValidate);
|
|
28
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export default (depth, i18n_active) => {
|
|
2
|
+
const n = depth - 1;
|
|
3
|
+
const body = Array.from({ length: n }, (_, i) => i - 1)
|
|
4
|
+
.reduceRight((child, _, i) => `
|
|
5
|
+
{#if p.components[${i + 1}]}
|
|
6
|
+
<svelte:component this={p.components[${i}]} request={p.request} {...p.props[${i}]}>
|
|
7
|
+
${child}
|
|
8
|
+
</svelte:component>
|
|
9
|
+
{:else}
|
|
10
|
+
<svelte:component this={p.components[${i}]} request={p.request} {...p.props[${i}]}/>
|
|
11
|
+
{/if}
|
|
12
|
+
`, `<svelte:component this={p.components[${n}]} request={p.request} {...p.props[${n}]}/>`);
|
|
13
|
+
const i18nImports = i18n_active
|
|
14
|
+
? `
|
|
15
|
+
import t from "#i18n";
|
|
16
|
+
import sInternal from "primate/s/internal";
|
|
17
|
+
import { onMount } from "svelte";`
|
|
18
|
+
: "";
|
|
19
|
+
const i18nInit = i18n_active
|
|
20
|
+
? `
|
|
21
|
+
const server = p.request.context.i18n.locale;
|
|
22
|
+
if (server !== undefined && server !== t.locale.get()) {
|
|
23
|
+
t[sInternal].init(server);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// after hydration: in storage modes, flip to saved locale once
|
|
27
|
+
onMount(() => { t[sInternal].restore(); });`
|
|
28
|
+
: "";
|
|
29
|
+
return `
|
|
30
|
+
<script>
|
|
31
|
+
import { afterUpdate, setContext } from "svelte";
|
|
32
|
+
import context_name from "@primate/svelte/context-name";
|
|
33
|
+
${i18nImports}
|
|
34
|
+
|
|
35
|
+
export let p;
|
|
36
|
+
|
|
37
|
+
// expose full request context to children (unchanged)
|
|
38
|
+
setContext(context_name, p.request.context);
|
|
39
|
+
|
|
40
|
+
${i18nInit}
|
|
41
|
+
|
|
42
|
+
// let the platform hook push heads after updates (unchanged)
|
|
43
|
+
afterUpdate(p.update);
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
${body}
|
|
47
|
+
`;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=create-root.js.map
|
package/package.json
CHANGED
|
@@ -1,65 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Primate Svelte frontend",
|
|
5
|
-
"homepage": "https://
|
|
6
|
-
"bugs": "https://github.com/
|
|
5
|
+
"homepage": "https://primate.run/docs/frontend/svelte",
|
|
6
|
+
"bugs": "https://github.com/primate-run/primate/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"files": [
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"/lib/**/*.js",
|
|
10
|
+
"/lib/**/*.d.ts",
|
|
11
|
+
"!/**/*.spec.*"
|
|
11
12
|
],
|
|
12
13
|
"repository": {
|
|
13
14
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/
|
|
15
|
+
"url": "https://github.com/primate-run/primate",
|
|
15
16
|
"directory": "packages/svelte"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"@rcompat/fs": "^0.
|
|
19
|
-
"@primate/
|
|
19
|
+
"@rcompat/fs": "^0.21.1",
|
|
20
|
+
"@primate/core": "^0.2.0"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
|
-
"svelte": "
|
|
23
|
-
"
|
|
24
|
-
"primate": "^0.32.1"
|
|
25
|
-
},
|
|
26
|
-
"peerDependenciesMeta": {
|
|
27
|
-
"@primate/i18n": {
|
|
28
|
-
"optional": true
|
|
29
|
-
}
|
|
23
|
+
"svelte": "5",
|
|
24
|
+
"primate": "^0.33.0"
|
|
30
25
|
},
|
|
31
26
|
"type": "module",
|
|
32
27
|
"imports": {
|
|
33
28
|
"#*": {
|
|
34
|
-
"
|
|
35
|
-
"default": "./
|
|
36
|
-
},
|
|
37
|
-
"#build": {
|
|
38
|
-
"@primate/lt": "./src/private/build/index.js",
|
|
39
|
-
"default": "./src/private/build/index.js"
|
|
40
|
-
},
|
|
41
|
-
"#serve": {
|
|
42
|
-
"@primate/lt": "./src/private/serve/index.js",
|
|
43
|
-
"default": "./src/private/serve/index.js"
|
|
44
|
-
},
|
|
45
|
-
"#client": {
|
|
46
|
-
"@primate/lt": "./src/private/client/index.js",
|
|
47
|
-
"default": "./src/private/client/index.js"
|
|
48
|
-
},
|
|
49
|
-
"#client/*": {
|
|
50
|
-
"@primate/lt": "./src/private/client/*.js",
|
|
51
|
-
"default": "./src/private/client/*.js"
|
|
52
|
-
},
|
|
53
|
-
"#i18n/*": {
|
|
54
|
-
"@primate/lt": "./src/private/i18n/*.js",
|
|
55
|
-
"default": "./src/private/i18n/*.js"
|
|
29
|
+
"apekit": "./src/private/*.ts",
|
|
30
|
+
"default": "./lib/private/*.js"
|
|
56
31
|
}
|
|
57
32
|
},
|
|
58
33
|
"exports": {
|
|
59
34
|
".": {
|
|
60
|
-
"
|
|
61
|
-
"
|
|
35
|
+
"browser": "./lib/public/browser.js",
|
|
36
|
+
"runtime": "./lib/public/runtime.js",
|
|
37
|
+
"default": "./lib/public/default.js"
|
|
62
38
|
},
|
|
63
|
-
"./*":
|
|
39
|
+
"./*": {
|
|
40
|
+
"apekit": "./src/public/*.ts",
|
|
41
|
+
"default": "./lib/public/*.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "npm run clean && tsc",
|
|
46
|
+
"clean": "rm -rf ./lib",
|
|
47
|
+
"lint": "eslint ."
|
|
64
48
|
}
|
|
65
49
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import create_root from "#client/create-root";
|
|
2
|
-
import expose from "#client/expose";
|
|
3
|
-
import name from "#name";
|
|
4
|
-
import build from "@primate/frontend/core/build";
|
|
5
|
-
import client from "./client.js";
|
|
6
|
-
import publish from "./publish.js";
|
|
7
|
-
import server from "./server.js";
|
|
8
|
-
|
|
9
|
-
export default extension => build({
|
|
10
|
-
create_root,
|
|
11
|
-
extension,
|
|
12
|
-
name,
|
|
13
|
-
actions: { compile: { client, server }, expose, publish },
|
|
14
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import file from "@rcompat/fs/file";
|
|
2
|
-
import webpath from "@rcompat/fs/webpath";
|
|
3
|
-
import client from "./client.js";
|
|
4
|
-
|
|
5
|
-
const css_filter = /\.sveltecss$/u;
|
|
6
|
-
const root_filter = /^root:svelte$/u;
|
|
7
|
-
|
|
8
|
-
export default (app, extension) => ({
|
|
9
|
-
name: "svelte",
|
|
10
|
-
setup(build) {
|
|
11
|
-
build.onResolve({ filter: css_filter }, ({ path }) => {
|
|
12
|
-
return { path, namespace: "sveltecss" };
|
|
13
|
-
});
|
|
14
|
-
build.onResolve({ filter: root_filter }, ({ path }) => {
|
|
15
|
-
return { path, namespace: "svelteroot" };
|
|
16
|
-
});
|
|
17
|
-
build.onLoad({ filter: css_filter }, ({ path }) => {
|
|
18
|
-
const contents = app.build.load(webpath(path));
|
|
19
|
-
return contents ? { contents, loader: "css", resolveDir: app.root.path } : null;
|
|
20
|
-
});
|
|
21
|
-
build.onLoad({ filter: root_filter }, ({ path }) => {
|
|
22
|
-
const contents = app.build.load(path);
|
|
23
|
-
return contents ? { contents, loader: "js", resolveDir: app.root.path } : null;
|
|
24
|
-
});
|
|
25
|
-
build.onLoad({ filter: new RegExp(`${extension}$`, "u") }, async args => {
|
|
26
|
-
// Load the file from the file system
|
|
27
|
-
const source = await file(args.path).text();
|
|
28
|
-
|
|
29
|
-
// Convert Svelte syntax to JavaScript
|
|
30
|
-
const { js, css } = client(source);
|
|
31
|
-
let contents = js;
|
|
32
|
-
if (css !== null && css !== "") {
|
|
33
|
-
const path = webpath(`${args.path}css`);
|
|
34
|
-
app.build.save(path, css);
|
|
35
|
-
contents += `\nimport "${path}";`;
|
|
36
|
-
}
|
|
37
|
-
return { contents };
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export default length => {
|
|
2
|
-
const n = length - 1;
|
|
3
|
-
const body = Array.from({ length: n }, (_, i) => i - 1)
|
|
4
|
-
.reduceRight((child, _, i) => `
|
|
5
|
-
{#if components[${i + 1}]}
|
|
6
|
-
<svelte:component this={components[${i}]} {request} {...data[${i}]}>
|
|
7
|
-
${child}
|
|
8
|
-
</svelte:component>
|
|
9
|
-
{:else}
|
|
10
|
-
<svelte:component this={components[${i}]} {request} {...data[${i}]}/>
|
|
11
|
-
{/if}
|
|
12
|
-
`, `<svelte:component this={components[${n}]} {request} {...data[${n}]}/>`);
|
|
13
|
-
|
|
14
|
-
return `
|
|
15
|
-
<script>
|
|
16
|
-
import { afterUpdate, setContext } from "svelte";
|
|
17
|
-
import context_name from "@primate/svelte/context-name";
|
|
18
|
-
|
|
19
|
-
export let components;
|
|
20
|
-
export let data;
|
|
21
|
-
export let request;
|
|
22
|
-
export let context;
|
|
23
|
-
export let update = () => undefined;
|
|
24
|
-
|
|
25
|
-
setContext(context_name, context);
|
|
26
|
-
|
|
27
|
-
afterUpdate(update);
|
|
28
|
-
</script>
|
|
29
|
-
${body}
|
|
30
|
-
`;
|
|
31
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default "export { setContext } from \"svelte\";";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import spa from "./spa.js";
|
|
2
|
-
|
|
3
|
-
export default ({ names, data, context, request }, options) => `
|
|
4
|
-
import * as components from "app";
|
|
5
|
-
let root = new components.root_svelte({
|
|
6
|
-
target: document.body,
|
|
7
|
-
hydrate: true,
|
|
8
|
-
props: {
|
|
9
|
-
components: [${names.map(name => `components.${name}`).join(", ")}],
|
|
10
|
-
data: ${JSON.stringify(data)},
|
|
11
|
-
context: ${JSON.stringify(context)},
|
|
12
|
-
request: {
|
|
13
|
-
...${JSON.stringify(request)},
|
|
14
|
-
url: new URL(location.href),
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
${options.spa ? spa : ""}`;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export default `
|
|
2
|
-
const { spa } = components;
|
|
3
|
-
window.addEventListener("DOMContentLoaded", _ => spa((props, update) => {
|
|
4
|
-
root.$destroy();
|
|
5
|
-
root = new components.root_svelte({
|
|
6
|
-
target: document.body,
|
|
7
|
-
hydrate: true,
|
|
8
|
-
props: {
|
|
9
|
-
components: props.names.map(name => components[name]),
|
|
10
|
-
data: props.data,
|
|
11
|
-
context: props.context,
|
|
12
|
-
request: {
|
|
13
|
-
...props.request,
|
|
14
|
-
url: new URL(location.href),
|
|
15
|
-
},
|
|
16
|
-
update,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
}));`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default "__PRMT__";
|
package/src/private/extension.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default ".svelte";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import context_name from "#context-name";
|
|
2
|
-
import locale_store from "#i18n/locale";
|
|
3
|
-
import resolve from "@primate/i18n/core/resolve";
|
|
4
|
-
import { getContext } from "svelte";
|
|
5
|
-
import { derived } from "svelte/store";
|
|
6
|
-
|
|
7
|
-
export default derived(locale_store, locale => (key, placeholders) => {
|
|
8
|
-
const { locales } = getContext(context_name).i18n;
|
|
9
|
-
return resolve(locales[locale], key, placeholders);
|
|
10
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import context_name from "#context-name";
|
|
2
|
-
import save from "@primate/i18n/core/save";
|
|
3
|
-
import { getContext } from "svelte";
|
|
4
|
-
import { writable } from "svelte/store";
|
|
5
|
-
|
|
6
|
-
const store = writable("", set => {
|
|
7
|
-
const { locale } = getContext(context_name).i18n;
|
|
8
|
-
set(locale);
|
|
9
|
-
|
|
10
|
-
return () => undefined;
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
subscribe: store.subscribe,
|
|
15
|
-
set: locale => {
|
|
16
|
-
store.set(locale);
|
|
17
|
-
save(locale);
|
|
18
|
-
},
|
|
19
|
-
};
|
package/src/private/name.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default "svelte";
|
package/src/private/pkgname.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default "@primate/svelte";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import client from "#client";
|
|
2
|
-
import name from "#name";
|
|
3
|
-
import handler from "@primate/frontend/core/handler";
|
|
4
|
-
import render from "./render.js";
|
|
5
|
-
|
|
6
|
-
export default (extension, spa) => (app, next) => {
|
|
7
|
-
app.register(extension, handler({
|
|
8
|
-
app,
|
|
9
|
-
render,
|
|
10
|
-
client,
|
|
11
|
-
name,
|
|
12
|
-
spa,
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
return next(app);
|
|
16
|
-
};
|
package/src/public/default.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import build from "#build";
|
|
2
|
-
import default_extension from "#extension";
|
|
3
|
-
import pkgname from "#pkgname";
|
|
4
|
-
import serve from "#serve";
|
|
5
|
-
|
|
6
|
-
export default ({
|
|
7
|
-
extension = default_extension,
|
|
8
|
-
// activate fetch-based browsing
|
|
9
|
-
spa = true,
|
|
10
|
-
} = {}) => ({
|
|
11
|
-
name: pkgname,
|
|
12
|
-
build: build(extension),
|
|
13
|
-
serve: serve(extension, spa),
|
|
14
|
-
});
|
package/src/public/i18n.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "#i18n/index";
|
package/src/public/locale.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "#i18n/locale";
|
package/src/public/runtime.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import default_extension from "#extension";
|
|
2
|
-
import pkgname from "#pkgname";
|
|
3
|
-
import serve from "#serve";
|
|
4
|
-
|
|
5
|
-
export default ({
|
|
6
|
-
extension = default_extension,
|
|
7
|
-
// activate fetch-based browsing
|
|
8
|
-
spa = true,
|
|
9
|
-
} = {}) => ({
|
|
10
|
-
name: pkgname,
|
|
11
|
-
serve: serve(extension, spa),
|
|
12
|
-
});
|