clarusjs 0.3.0 → 0.5.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.
Files changed (41) hide show
  1. package/README.md +5 -5
  2. package/dist/check/generate.d.ts +27 -0
  3. package/dist/check/generate.js +234 -0
  4. package/dist/cli/check.d.ts +17 -0
  5. package/dist/cli/check.js +101 -0
  6. package/dist/cli/explain.d.ts +9 -0
  7. package/dist/cli/explain.js +56 -0
  8. package/dist/cli/index.d.ts +2 -0
  9. package/dist/cli/index.js +38 -0
  10. package/dist/compiler/emit-client.js +2 -0
  11. package/dist/compiler/emit-server.d.ts +1 -1
  12. package/dist/compiler/emit-server.js +4 -2
  13. package/dist/compiler/errors.d.ts +1 -1
  14. package/dist/compiler/errors.js +1 -1
  15. package/dist/compiler/index.d.ts +5 -0
  16. package/dist/compiler/index.js +1 -1
  17. package/dist/compiler/ir.d.ts +2 -1
  18. package/dist/compiler/ir.js +14 -4
  19. package/dist/compiler/parse.d.ts +22 -0
  20. package/dist/compiler/parse.js +52 -14
  21. package/dist/compiler/script.d.ts +5 -1
  22. package/dist/compiler/script.js +2 -1
  23. package/dist/runtime/router.d.ts +15 -0
  24. package/dist/runtime/router.js +101 -0
  25. package/dist/server/handler.d.ts +25 -1
  26. package/dist/server/handler.js +170 -9
  27. package/dist/server/manifest.d.ts +4 -0
  28. package/dist/server/manifest.js +17 -0
  29. package/dist/server/modes.d.ts +6 -0
  30. package/dist/server/modes.js +28 -0
  31. package/dist/server/views.d.ts +17 -0
  32. package/dist/server/views.js +23 -0
  33. package/dist/vite/build.d.ts +18 -5
  34. package/dist/vite/build.js +49 -12
  35. package/dist/vite/manifest.d.ts +49 -0
  36. package/dist/vite/manifest.js +86 -0
  37. package/dist/vite/netlify.d.ts +4 -0
  38. package/dist/vite/netlify.js +46 -0
  39. package/dist/vite/plugin.d.ts +8 -1
  40. package/dist/vite/plugin.js +134 -20
  41. package/package.json +14 -2
@@ -0,0 +1,28 @@
1
+ // Per-route rendering modes: when each route renders. 'static' at build (the default), 'server' per request,
2
+ // 'client' in the browser (the server sends a shell; the router renders the page from its data).
3
+ const MODES = ['static', 'server', 'client'];
4
+ /** Throws on an unknown mode or a malformed pattern, naming it. */
5
+ export function checkModes(table) {
6
+ for (const [pattern, mode] of Object.entries(table)) {
7
+ if (!pattern.startsWith('/'))
8
+ throw new Error(`clarusjs: route pattern "${pattern}" must start with /`);
9
+ if (pattern.slice(0, -1).includes('*') || (pattern.endsWith('*') && !pattern.endsWith('/*'))) {
10
+ throw new Error(`clarusjs: route pattern "${pattern}" may only use * as its last segment`);
11
+ }
12
+ if (!MODES.includes(mode))
13
+ throw new Error(`clarusjs: routes['${pattern}'] is "${mode}"; use 'static', 'server' or 'client'`);
14
+ }
15
+ }
16
+ /** The mode of a route (as its file names it, e.g. '/account/[id]'): the most specific matching pattern wins. */
17
+ export function modeFor(route, table) {
18
+ let best;
19
+ for (const [pattern, mode] of Object.entries(table)) {
20
+ const folder = pattern.endsWith('/*') ? pattern.slice(0, -2) : undefined;
21
+ const hit = folder !== undefined ? route === (folder || '/') || route.startsWith(`${folder}/`) : route === pattern;
22
+ // An exact pattern beats a folder of the same length.
23
+ const length = folder !== undefined ? folder.length : pattern.length + 0.5;
24
+ if (hit && (!best || length > best.length))
25
+ best = { length, mode: mode };
26
+ }
27
+ return best?.mode ?? 'static';
28
+ }
@@ -0,0 +1,17 @@
1
+ type View = {
2
+ render(props?: object): string;
3
+ };
4
+ type Registry = Record<string, () => Promise<View>>;
5
+ /** View name → inputs. Filled in by the generated .clarusjs/views.d.ts (declaration merging). */
6
+ export interface Views {
7
+ }
8
+ /** Without the generated registry any name is accepted; with it, only real views. */
9
+ export type ViewName = [keyof Views] extends [never] ? string : Extract<keyof Views, string>;
10
+ export type ViewProps<N> = N extends keyof Views ? Views[N] : Record<string, unknown>;
11
+ /** '/src/components/pill.tscl' → 'components/pill' */
12
+ export declare function viewName(file: string): string;
13
+ /** Called by the server entry with import.meta.glob('/src/**\/*.tscl'). */
14
+ export declare function registerViews(files: Registry): void;
15
+ /** Render a view to HTML. Its props are checked against its inputs once `clarusjs check` has generated the registry. */
16
+ export declare function render<N extends ViewName>(name: N, props: ViewProps<N>): Promise<string>;
17
+ export {};
@@ -0,0 +1,23 @@
1
+ // render(name, props): any view under src/ rendered to HTML from server code (a loader, an endpoint, a script that
2
+ // imports the built server). The server entry registers the views; `clarusjs check` writes .clarusjs/views.d.ts,
3
+ // which types each name with that view's inputs.
4
+ /** '/src/components/pill.tscl' → 'components/pill' */
5
+ export function viewName(file) {
6
+ return file.replace(/^.*?\/src\//, '').replace(/\.tscl$/, '');
7
+ }
8
+ // On globalThis: the bundled server and an app's own `import 'clarusjs/views'` may be two copies of this module.
9
+ const store = globalThis;
10
+ /** Called by the server entry with import.meta.glob('/src/**\/*.tscl'). */
11
+ export function registerViews(files) {
12
+ store.__clViews = new Map(Object.entries(files).map(([file, load]) => [viewName(file), load]));
13
+ }
14
+ /** Render a view to HTML. Its props are checked against its inputs once `clarusjs check` has generated the registry. */
15
+ export async function render(name, props) {
16
+ const views = store.__clViews;
17
+ if (!views)
18
+ throw new Error('clarusjs: no views are registered; render() runs in server code, after the server entry has loaded');
19
+ const load = views.get(name);
20
+ if (!load)
21
+ throw new Error(`clarusjs: no view "${name}"; views: ${[...views.keys()].sort().join(', ')}`);
22
+ return (await load()).render(props);
23
+ }
@@ -1,9 +1,22 @@
1
- /** Absolute paths of every `.clarus` file under `srcDir` (empty if it doesn't exist). */
1
+ /** Absolute paths of every `.tscl` file under `srcDir` (empty if it doesn't exist). */
2
2
  export declare function findClarusFiles(srcDir: string): string[];
3
- /** '/' → 'index.html', '/about/team' → 'about/team/index.html' */
3
+ /**
4
+ * '/' → 'index.html', '/about/team' → 'about/team/index.html', '/users/a%20b' → 'users/a b/index.html'.
5
+ * Segments are decoded because static hosts look files up by the decoded path. A decoded segment can't add a level:
6
+ * entries() values never contain '/' (and a page file's own name has none).
7
+ */
4
8
  export declare function routeToFile(route: string): string;
5
9
  /**
6
- * Call the built handler for every route and write the HTML into `outDir`. Any failure fails the build.
7
- * Runs in a fresh Node process so a rebuilt server bundle is never served from a module cache.
10
+ * Call the built handler for every route (or only `only`) and write the HTML into `outDir`. Any failure fails the
11
+ * build. Runs in a fresh Node process so a rebuilt server bundle is never served from a module cache. Returns the
12
+ * routes rendered and those that read the route manifest (readManifest() from `manifestFile`).
8
13
  */
9
- export declare function prerender(serverEntry: string, outDir: string): Promise<string[]>;
14
+ export declare function prerender(serverEntry: string, outDir: string, manifestFile: string, only?: string[]): Promise<{
15
+ routes: string[];
16
+ readers: string[];
17
+ loaded: string[];
18
+ server: {
19
+ route: string;
20
+ loader: boolean;
21
+ }[];
22
+ }>;
@@ -2,7 +2,7 @@
2
2
  import { spawnSync } from 'node:child_process';
3
3
  import { readdirSync } from 'node:fs';
4
4
  import { resolve } from 'node:path';
5
- /** Absolute paths of every `.clarus` file under `srcDir` (empty if it doesn't exist). */
5
+ /** Absolute paths of every `.tscl` file under `srcDir` (empty if it doesn't exist). */
6
6
  export function findClarusFiles(srcDir) {
7
7
  let entries;
8
8
  try {
@@ -11,26 +11,52 @@ export function findClarusFiles(srcDir) {
11
11
  catch {
12
12
  return [];
13
13
  }
14
- return entries.filter((f) => f.endsWith('.clarus')).map((f) => resolve(srcDir, f)).sort();
14
+ return entries.filter((f) => f.endsWith('.tscl')).map((f) => resolve(srcDir, f)).sort();
15
15
  }
16
- /** '/' → 'index.html', '/about/team' → 'about/team/index.html' */
16
+ /**
17
+ * '/' → 'index.html', '/about/team' → 'about/team/index.html', '/users/a%20b' → 'users/a b/index.html'.
18
+ * Segments are decoded because static hosts look files up by the decoded path. A decoded segment can't add a level:
19
+ * entries() values never contain '/' (and a page file's own name has none).
20
+ */
17
21
  export function routeToFile(route) {
18
- const path = route.replace(/^\/+|\/+$/g, '');
22
+ const path = route.replace(/^\/+|\/+$/g, '').split('/').map((seg) => {
23
+ try {
24
+ return decodeURIComponent(seg);
25
+ }
26
+ catch {
27
+ return seg;
28
+ } // '100%' is a name, not an escape
29
+ }).join('/');
30
+ // A client page's data file is written as itself, next to the page's shell.
31
+ if (path === '__data.json' || path.endsWith('/__data.json'))
32
+ return path;
19
33
  return path ? `${path}/index.html` : 'index.html';
20
34
  }
21
35
  /**
22
- * Call the built handler for every route and write the HTML into `outDir`. Any failure fails the build.
23
- * Runs in a fresh Node process so a rebuilt server bundle is never served from a module cache.
36
+ * Call the built handler for every route (or only `only`) and write the HTML into `outDir`. Any failure fails the
37
+ * build. Runs in a fresh Node process so a rebuilt server bundle is never served from a module cache. Returns the
38
+ * routes rendered and those that read the route manifest (readManifest() from `manifestFile`).
24
39
  */
25
- export async function prerender(serverEntry, outDir) {
40
+ export async function prerender(serverEntry, outDir, manifestFile, only) {
26
41
  const script = `
27
42
  import { mkdirSync, writeFileSync } from 'node:fs'
28
- import { dirname, resolve } from 'node:path'
43
+ import { dirname, resolve, sep } from 'node:path'
29
44
  import { pathToFileURL } from 'node:url'
30
45
  const routeToFile = ${routeToFile.toString()}
31
- const [entry, outDir] = process.argv.slice(1)
46
+ const [entry, outDir, only] = process.argv.slice(1)
32
47
  const { default: handler } = await import(pathToFileURL(entry).href)
33
- for (const route of handler.routes) {
48
+ let routes
49
+ try {
50
+ routes = only ? JSON.parse(only) : await handler.paths()
51
+ } catch (err) {
52
+ process.stderr.write('prerender: ' + (err && err.message || err))
53
+ process.exit(1)
54
+ }
55
+ const readers = []
56
+ const loaded = []
57
+ for (const route of routes) {
58
+ globalThis.__clManifestRead = false
59
+ globalThis.__clLoaderRan = false
34
60
  let response
35
61
  try {
36
62
  response = await handler.fetch(new Request('http://localhost' + route))
@@ -43,12 +69,23 @@ export async function prerender(serverEntry, outDir) {
43
69
  process.exit(1)
44
70
  }
45
71
  const file = resolve(outDir, routeToFile(route))
72
+ // Whatever a route decodes to, its page must land inside the output folder.
73
+ if (!file.startsWith(resolve(outDir) + sep)) {
74
+ process.stderr.write('prerender ' + route + ': outside the output folder')
75
+ process.exit(1)
76
+ }
46
77
  mkdirSync(dirname(file), { recursive: true })
47
78
  writeFileSync(file, await response.text())
79
+ if (globalThis.__clManifestRead) readers.push(route)
80
+ if (globalThis.__clLoaderRan) loaded.push(route)
48
81
  }
49
- process.stdout.write(JSON.stringify(handler.routes))
82
+ const server = []
83
+ for (const route of handler.serverRoutes ?? []) server.push({ route, loader: await handler.hasLoader(route) })
84
+ process.stdout.write(JSON.stringify({ routes, readers, loaded, server }))
50
85
  `;
51
- const result = spawnSync(process.execPath, ['--input-type=module', '-e', script, serverEntry, outDir], { encoding: 'utf8' });
86
+ const args = ['--input-type=module', '-e', script, serverEntry, outDir, ...(only ? [JSON.stringify(only)] : [])];
87
+ const env = { ...process.env, CLARUS_MANIFEST: manifestFile };
88
+ const result = spawnSync(process.execPath, args, { encoding: 'utf8', env });
52
89
  if (result.status !== 0)
53
90
  throw new Error(result.stderr.trim() || `prerender failed (exit ${result.status})`);
54
91
  return JSON.parse(result.stdout);
@@ -0,0 +1,49 @@
1
+ export type Attach = 'load' | 'idle' | 'visible' | 'interaction';
2
+ export type IslandInfo = {
3
+ component: string;
4
+ src: string;
5
+ attach: Attach;
6
+ count: number;
7
+ gzip: number;
8
+ };
9
+ export type RouteInfo = {
10
+ /**
11
+ * 'static': prerendered at build. 'server': rendered per request by dist/server/index.mjs (its key is the route as
12
+ * its file names it). 'client': a prerendered shell; the router renders it in the browser from its __data.json.
13
+ */
14
+ mode: 'static' | 'server' | 'client';
15
+ /** The prerendered file in dist/client (a client route's shell), or null for a server route. */
16
+ html: string | null;
17
+ /** 'build': load() ran once, when the page was prerendered. 'request': it runs on every request. */
18
+ loader: 'build' | 'request' | null;
19
+ islands: IslandInfo[];
20
+ /** Files relative to dist/client; gzip sizes in bytes. initialGzip is what loads with the page (attach="load"). */
21
+ js: {
22
+ files: string[];
23
+ gzip: number;
24
+ initialGzip: number;
25
+ };
26
+ css: string[];
27
+ };
28
+ export type Manifest = {
29
+ version: 1;
30
+ routes: Record<string, RouteInfo>;
31
+ };
32
+ /** Vite's client manifest (dist/client/.vite/manifest.json). */
33
+ export type ChunkGraph = Record<string, {
34
+ file: string;
35
+ imports?: string[];
36
+ }>;
37
+ /** What one prerendered page ships. `size` returns a built file's gzip size. */
38
+ export declare function describeRoute(route: string, html: string, opts: {
39
+ base: string;
40
+ chunks: ChunkGraph;
41
+ size(file: string): number;
42
+ loaded?: boolean;
43
+ client?: boolean;
44
+ }): RouteInfo;
45
+ /** Describe every prerendered route and write `<distDir>/clarusjs-manifest.json`. */
46
+ export declare function writeManifest(distDir: string, routes: string[], base: string, loaded?: string[], server?: {
47
+ route: string;
48
+ loader: boolean;
49
+ }[]): Manifest;
@@ -0,0 +1,86 @@
1
+ // The route manifest: after `vite build`, what each page ships, read back from its prerendered HTML.
2
+ // dist/clarusjs-manifest.json is what `clarusjs explain` prints. Written outside dist/client, so it isn't served.
3
+ import { readFileSync, writeFileSync } from 'node:fs';
4
+ import { resolve } from 'node:path';
5
+ import { gzipSync } from 'node:zlib';
6
+ import { routeToFile } from './build.js';
7
+ import { matchRoute } from '../runtime/router.js';
8
+ const attrsOf = (tag) => {
9
+ const out = {};
10
+ for (const m of tag.matchAll(/([\w-]+)="([^"]*)"/g))
11
+ out[m[1]] = m[2].replace(/&amp;/g, '&');
12
+ return out;
13
+ };
14
+ /** What one prerendered page ships. `size` returns a built file's gzip size. */
15
+ export function describeRoute(route, html, opts) {
16
+ const local = (url) => (url.startsWith(opts.base) ? url.slice(opts.base.length) : url.replace(/^\//, ''));
17
+ const byFile = new Map(Object.values(opts.chunks).map((c) => [c.file, c]));
18
+ const keyFile = new Map(Object.entries(opts.chunks).map(([k, c]) => [k, c.file]));
19
+ // A chunk and everything it imports, in load order.
20
+ const closure = (file, into) => {
21
+ if (into.includes(file))
22
+ return;
23
+ into.push(file);
24
+ for (const imp of byFile.get(file)?.imports ?? [])
25
+ closure(keyFile.get(imp) ?? imp, into);
26
+ };
27
+ const islands = [];
28
+ for (const m of html.matchAll(/<cl-island\b([^>]*)>/g)) {
29
+ const a = attrsOf(m[1]);
30
+ const attach = (a.a ?? 'load');
31
+ const src = local(a.src ?? '');
32
+ const same = islands.find((i) => i.component === a.c && i.attach === attach);
33
+ if (same)
34
+ same.count++;
35
+ else
36
+ islands.push({ component: a.c ?? '', src, attach, count: 1, gzip: opts.size(src) });
37
+ }
38
+ const all = [];
39
+ const initial = [];
40
+ for (const m of html.matchAll(/<script type="module" src="([^"]+)"><\/script>/g)) {
41
+ closure(local(m[1]), all);
42
+ closure(local(m[1]), initial);
43
+ }
44
+ // A client route also loads its page's render module, named in the shell's route table.
45
+ const table = /<script type="application\/json" id="cl-routes">(.*?)<\/script>/.exec(html)?.[1];
46
+ const render = opts.client && table ? matchRoute(JSON.parse(table), route)?.r : undefined;
47
+ if (render) {
48
+ closure(local(render), all);
49
+ closure(local(render), initial);
50
+ }
51
+ for (const island of islands) {
52
+ closure(island.src, all);
53
+ if (island.attach === 'load')
54
+ closure(island.src, initial);
55
+ }
56
+ const sum = (files) => files.reduce((n, f) => n + opts.size(f), 0);
57
+ const css = [...html.matchAll(/<link\b[^>]*rel="stylesheet"[^>]*>/g)].map((m) => attrsOf(m[0]).href).filter(Boolean);
58
+ return { mode: opts.client ? 'client' : 'static', html: routeToFile(route), loader: opts.loaded ? 'build' : null, islands, js: { files: all, gzip: sum(all), initialGzip: sum(initial) }, css };
59
+ }
60
+ /** Describe every prerendered route and write `<distDir>/clarusjs-manifest.json`. */
61
+ export function writeManifest(distDir, routes, base, loaded = [], server = []) {
62
+ const client = resolve(distDir, 'client');
63
+ const chunks = JSON.parse(readFileSync(resolve(client, '.vite/manifest.json'), 'utf8'));
64
+ const sizes = new Map();
65
+ const size = (file) => {
66
+ if (!sizes.has(file))
67
+ sizes.set(file, gzipSync(readFileSync(resolve(client, file)), { level: 9 }).length);
68
+ return sizes.get(file);
69
+ };
70
+ const manifest = { version: 1, routes: {} };
71
+ const dataFile = (route) => (route === '/' ? '/__data.json' : `${route}/__data.json`);
72
+ for (const route of routes) {
73
+ if (route.endsWith('/__data.json'))
74
+ continue; // a client route's data, not a page
75
+ const isClient = routes.includes(dataFile(route));
76
+ // A client route's loader runs when its data file is written.
77
+ const ran = loaded.includes(route) || (isClient && loaded.includes(dataFile(route)));
78
+ manifest.routes[route] = describeRoute(route, readFileSync(resolve(client, routeToFile(route)), 'utf8'), { base, chunks, size, loaded: ran, client: isClient });
79
+ }
80
+ // Server routes have no HTML at build time: what they ship is decided per request.
81
+ for (const { route, loader } of server) {
82
+ manifest.routes[route] = { mode: 'server', html: null, loader: loader ? 'request' : null, islands: [], js: { files: [], gzip: 0, initialGzip: 0 }, css: [] };
83
+ }
84
+ writeFileSync(resolve(distDir, 'clarusjs-manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`);
85
+ return manifest;
86
+ }
@@ -0,0 +1,4 @@
1
+ /** '/account/[id]' → ['/account/:id', '/account/:id/'] (Netlify paths use URLPattern syntax). */
2
+ export declare function netlifyPaths(route: string): string[];
3
+ /** Write (or, without server routes, remove) the function in `<root>/.netlify/v1/functions`. */
4
+ export declare function writeNetlifyFunction(root: string, serverEntry: string, serverRoutes: string[]): void;
@@ -0,0 +1,46 @@
1
+ // Netlify adapter: server routes run as one Netlify Function (Frameworks API) calling the same fetch handler.
2
+ // Static routes stay files; preferStatic makes Netlify serve those first.
3
+ import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
4
+ import { dirname, relative, resolve, sep } from 'node:path';
5
+ const FUNCTION = '.netlify/v1/functions/clarusjs-server.mjs';
6
+ /** '/account/[id]' → ['/account/:id', '/account/:id/'] (Netlify paths use URLPattern syntax). */
7
+ export function netlifyPaths(route) {
8
+ const segments = route.split('/');
9
+ const keyOf = (seg) => /^\[([A-Za-z_$][\w$]*)\]$/.exec(seg)?.[1];
10
+ const valid = (key) => /^[A-Za-z_]\w*$/.test(key);
11
+ // Names already valid in URLPattern are kept; others get p0, p1, … that aren't taken (URLPattern rejects duplicates).
12
+ const taken = new Set(segments.map(keyOf).filter((k) => k !== undefined && valid(k)));
13
+ let n = 0;
14
+ const fresh = () => {
15
+ while (taken.has(`p${n}`))
16
+ n++;
17
+ taken.add(`p${n}`);
18
+ return `p${n}`;
19
+ };
20
+ const path = segments.map((seg) => {
21
+ const key = keyOf(seg);
22
+ if (key !== undefined)
23
+ return `:${valid(key) ? key : fresh()}`;
24
+ return seg.replace(/[:*?+(){}\\]/g, '\\$&'); // literal text, not pattern syntax
25
+ }).join('/');
26
+ return path === '/' || path === '' ? ['/'] : [path, `${path}/`];
27
+ }
28
+ /** Write (or, without server routes, remove) the function in `<root>/.netlify/v1/functions`. */
29
+ export function writeNetlifyFunction(root, serverEntry, serverRoutes) {
30
+ const file = resolve(root, FUNCTION);
31
+ if (!serverRoutes.length) {
32
+ rmSync(file, { force: true });
33
+ return;
34
+ }
35
+ const entry = relative(dirname(file), serverEntry).split(sep).join('/');
36
+ mkdirSync(dirname(file), { recursive: true });
37
+ writeFileSync(file, [
38
+ '// Generated by clarusjs: server routes on Netlify Functions. Static routes are files.',
39
+ `import handler from ${JSON.stringify(entry.startsWith('.') ? entry : `./${entry}`)}`,
40
+ '',
41
+ 'export default (request) => handler.fetch(request)',
42
+ '',
43
+ `export const config = ${JSON.stringify({ path: serverRoutes.flatMap(netlifyPaths), preferStatic: true })}`,
44
+ '',
45
+ ].join('\n'));
46
+ }
@@ -1,4 +1,11 @@
1
1
  import { type Plugin } from 'vite';
2
+ import { type ModeTable } from '../server/modes.ts';
2
3
  /** Dev URL of a component's client module: root-relative, or Vite's /@fs/ form for files outside the root. */
3
4
  export declare function clientUrlFor(root: string, file: string): string;
4
- export default function clarusjs(): Plugin;
5
+ export type ClarusOptions = {
6
+ /** When each route renders: { '/account/*': 'server' }. Routes default to 'static' (prerendered at build). */
7
+ routes?: ModeTable;
8
+ /** Where server routes deploy. 'netlify': a Netlify Function (Frameworks API) next to the static files. */
9
+ adapter?: 'netlify';
10
+ };
11
+ export default function clarusjs(options?: ClarusOptions): Plugin;