@pajecawav/yamf 0.0.9 → 0.0.10

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.
@@ -31,7 +31,8 @@ const requestIdle = (callback) => {
31
31
  * element (src/client/index.ts) once this runtime module has been loaded.
32
32
  */
33
33
  const hydrateIsland = (island) => {
34
- const islandProps = parse(island.getAttribute("island-props") ?? "{}");
34
+ const rawProps = island.getAttribute("island-props");
35
+ const islandProps = rawProps === null ? [] : parse(rawProps);
35
36
  const islandSrc = island.getAttribute("island-src");
36
37
  const islandEntry = island.getAttribute("island-entry");
37
38
  const islandClient = island.getAttribute("island-client") ?? "load";
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":[],"sources":["../../src/island/client.tsx"],"sourcesContent":["import { parse } from \"devalue\";\nimport type { FC } from \"hono/jsx\";\nimport { hydrateRoot } from \"hono/jsx/dom/client\";\nimport { withLeadingSlash } from \"ufo\";\nimport type { IslandClientDirectiveSerialized } from \"./types\";\n\ndeclare let __yamf_raw_import__: <T>(file: string) => Promise<T>;\n\nconst listeners: WeakMap<Element, VoidFunction> = new WeakMap();\n\nconst observer: IntersectionObserver = new IntersectionObserver(entries => {\n\tfor (const entry of entries) {\n\t\tif (entry.isIntersecting) {\n\t\t\tlisteners.get(entry.target)?.();\n\t\t\tunobserve(entry.target);\n\t\t}\n\t}\n});\n\nconst observe = (target: Element, cb: VoidFunction) => {\n\tobserver.observe(target);\n\tlisteners.set(target, cb);\n};\n\nconst unobserve = (target: Element) => {\n\tobserver.unobserve(target);\n\tlisteners.delete(target);\n};\n\n// Safari does not enable requestIdleCallback by default in any stable\n// release — without a fallback, client:idle islands never hydrate there\nconst requestIdle = (callback: () => void): void => {\n\tconst ric = window.requestIdleCallback;\n\n\tif (typeof ric === \"function\") {\n\t\tric(callback);\n\t\treturn;\n\t}\n\n\tsetTimeout(callback, 1);\n};\n\n/**\n * Hydrates a single <yamf-island> island. Called by the bootstrap custom\n * element (src/client/index.ts) once this runtime module has been loaded.\n */\nexport const hydrateIsland = (island: HTMLElement): void => {\n\tconst islandProps = parse(island.getAttribute(\"island-props\") ?? \"{}\");\n\tconst islandSrc = island.getAttribute(\"island-src\");\n\tconst islandEntry = island.getAttribute(\"island-entry\");\n\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion\n\tconst islandClient = (island.getAttribute(\"island-client\") ??\n\t\t\"load\") as IslandClientDirectiveSerialized;\n\n\tif (!islandSrc) {\n\t\tthrow new Error(\"Missing island-src attribute\");\n\t}\n\n\tif (!islandEntry) {\n\t\tthrow new Error(\"Missing island-entry attribute\");\n\t}\n\n\tconst hydrate = (mod: Record<string, FC>) => {\n\t\tconst Comp = mod[islandEntry];\n\n\t\tif (!Comp) {\n\t\t\tthrow new Error(`Missing island entry ${islandEntry} in ${islandSrc}`);\n\t\t}\n\n\t\thydrateRoot(island, <Comp {...islandProps} />);\n\t};\n\n\tconst initIsland = () => {\n\t\tconst src = withLeadingSlash(islandSrc);\n\t\tvoid __yamf_raw_import__<Record<string, FC>>(src).then(hydrate);\n\t};\n\n\tswitch (islandClient) {\n\t\tcase \"true\":\n\t\tcase \"load\":\n\t\t\tinitIsland();\n\t\t\tbreak;\n\t\tcase \"idle\":\n\t\t\trequestIdle(initIsland);\n\t\t\tbreak;\n\t\tcase \"visible\":\n\t\t\t// yamf-island has `display: contents` which breaks IntersectionObserver\n\t\t\t// so we have to observe the first child instead if it exists\n\t\t\tif (island.firstElementChild) {\n\t\t\t\tobserve(island.firstElementChild, initIsland);\n\t\t\t} else {\n\t\t\t\tinitIsland();\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"false\":\n\t\tcase \"skip\":\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tislandClient satisfies never;\n\t\t\t// oxlint-disable-next-line typescript/restrict-template-expressions\n\t\t\tthrow new Error(`Invalid island-client value: ${islandClient}`);\n\t}\n};\n"],"mappings":";;;;;AAQA,MAAM,4BAA4C,IAAI,QAAQ;AAE9D,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mBAAmB,UAAU;QAE5C,WAAW;GAEZ;EACD,KAAK;EACL,KAAK,QACJ;EACD,SAGC,MAAM,IAAI,MAAM,gCAAgC,cAAc;CAChE;AACD"}
1
+ {"version":3,"file":"client.js","names":[],"sources":["../../src/island/client.tsx"],"sourcesContent":["import { parse } from \"devalue\";\nimport type { FC } from \"hono/jsx\";\nimport { hydrateRoot } from \"hono/jsx/dom/client\";\nimport { withLeadingSlash } from \"ufo\";\nimport type { IslandClientDirectiveSerialized } from \"./types\";\n\ndeclare let __yamf_raw_import__: <T>(file: string) => Promise<T>;\n\nconst listeners: WeakMap<Element, VoidFunction> = new WeakMap();\n\nconst observer: IntersectionObserver = new IntersectionObserver(entries => {\n\tfor (const entry of entries) {\n\t\tif (entry.isIntersecting) {\n\t\t\tlisteners.get(entry.target)?.();\n\t\t\tunobserve(entry.target);\n\t\t}\n\t}\n});\n\nconst observe = (target: Element, cb: VoidFunction) => {\n\tobserver.observe(target);\n\tlisteners.set(target, cb);\n};\n\nconst unobserve = (target: Element) => {\n\tobserver.unobserve(target);\n\tlisteners.delete(target);\n};\n\n// Safari does not enable requestIdleCallback by default in any stable\n// release — without a fallback, client:idle islands never hydrate there\nconst requestIdle = (callback: () => void): void => {\n\tconst ric = window.requestIdleCallback;\n\n\tif (typeof ric === \"function\") {\n\t\tric(callback);\n\t\treturn;\n\t}\n\n\tsetTimeout(callback, 1);\n};\n\n/**\n * Hydrates a single <yamf-island> island. Called by the bootstrap custom\n * element (src/client/index.ts) once this runtime module has been loaded.\n */\nexport const hydrateIsland = (island: HTMLElement): void => {\n\t// skip islands omit the attribute entirely — parse after (and only if) it\n\t// exists, otherwise parse(\"{}\") would throw \"Invalid input\" and abort the\n\t// whole pending-hydration loop\n\tconst rawProps = island.getAttribute(\"island-props\");\n\tconst islandProps = rawProps === null ? [] : parse(rawProps);\n\tconst islandSrc = island.getAttribute(\"island-src\");\n\tconst islandEntry = island.getAttribute(\"island-entry\");\n\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion\n\tconst islandClient = (island.getAttribute(\"island-client\") ??\n\t\t\"load\") as IslandClientDirectiveSerialized;\n\n\tif (!islandSrc) {\n\t\tthrow new Error(\"Missing island-src attribute\");\n\t}\n\n\tif (!islandEntry) {\n\t\tthrow new Error(\"Missing island-entry attribute\");\n\t}\n\n\tconst hydrate = (mod: Record<string, FC>) => {\n\t\tconst Comp = mod[islandEntry];\n\n\t\tif (!Comp) {\n\t\t\tthrow new Error(`Missing island entry ${islandEntry} in ${islandSrc}`);\n\t\t}\n\n\t\thydrateRoot(island, <Comp {...islandProps} />);\n\t};\n\n\tconst initIsland = () => {\n\t\tconst src = withLeadingSlash(islandSrc);\n\t\tvoid __yamf_raw_import__<Record<string, FC>>(src).then(hydrate);\n\t};\n\n\tswitch (islandClient) {\n\t\tcase \"true\":\n\t\tcase \"load\":\n\t\t\tinitIsland();\n\t\t\tbreak;\n\t\tcase \"idle\":\n\t\t\trequestIdle(initIsland);\n\t\t\tbreak;\n\t\tcase \"visible\":\n\t\t\t// yamf-island has `display: contents` which breaks IntersectionObserver\n\t\t\t// so we have to observe the first child instead if it exists\n\t\t\tif (island.firstElementChild) {\n\t\t\t\tobserve(island.firstElementChild, initIsland);\n\t\t\t} else {\n\t\t\t\tinitIsland();\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"false\":\n\t\tcase \"skip\":\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tislandClient satisfies never;\n\t\t\t// oxlint-disable-next-line typescript/restrict-template-expressions\n\t\t\tthrow new Error(`Invalid island-client value: ${islandClient}`);\n\t}\n};\n"],"mappings":";;;;;AAQA,MAAM,4BAA4C,IAAI,QAAQ;AAE9D,MAAM,WAAiC,IAAI,sBAAqB,YAAW;CAC1E,KAAK,MAAM,SAAS,SACnB,IAAI,MAAM,gBAAgB;EACzB,UAAU,IAAI,MAAM,MAAM,CAAC,GAAG;EAC9B,UAAU,MAAM,MAAM;CACvB;AAEF,CAAC;AAED,MAAM,WAAW,QAAiB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
  {
2
2
  "name": "@pajecawav/yamf",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "description": "Yet another meta framework",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/pajecawav/yamf#readme",
@@ -43,30 +43,30 @@
43
43
  "@hono/react-compat": "^0.0.3",
44
44
  "@standard-schema/spec": "^1.1.0",
45
45
  "devalue": "^6.0.2",
46
- "exsolve": "^1.1.1",
46
+ "exsolve": "^1.1.3",
47
47
  "nitro": "3.0.260903-beta",
48
48
  "rolldown-string": "^0.3.1",
49
- "rou3": "^0.9.2",
49
+ "rou3": "^1.0.0",
50
50
  "ufo": "^1.6.4",
51
- "unhead": "^3.4.1",
52
- "wouter": "^3.11.0"
51
+ "unhead": "^3.4.2",
52
+ "wouter": "^3.13.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@hono/react-compat": "^0.0.3",
56
- "@pajecawav/tools": "^0.0.9",
56
+ "@pajecawav/tools": "^0.1.0",
57
57
  "@playwright/test": "^1.63.0",
58
- "@types/node": "^26.6.2",
58
+ "@types/node": "^26.6.4",
59
59
  "cross-env": "^10.1.0",
60
- "hono": "^4.13.9",
60
+ "hono": "^4.13.12",
61
61
  "husky": "^9.1.7",
62
62
  "npm-run-all2": "^9.0.3",
63
- "oxfmt": "^0.70.0",
64
- "oxlint": "^1.85.0",
63
+ "oxfmt": "^0.71.0",
64
+ "oxlint": "^1.86.0",
65
65
  "oxlint-tsgolint": "^7.0.2002",
66
- "publint": "^0.3.24",
66
+ "publint": "^0.3.25",
67
67
  "tsdown": "0.23.0",
68
68
  "typescript": "~7.0.2",
69
- "vite": "^8.3.0"
69
+ "vite": "^8.3.2"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "tsdown",
@@ -45,7 +45,11 @@ const requestIdle = (callback: () => void): void => {
45
45
  * element (src/client/index.ts) once this runtime module has been loaded.
46
46
  */
47
47
  export const hydrateIsland = (island: HTMLElement): void => {
48
- const islandProps = parse(island.getAttribute("island-props") ?? "{}");
48
+ // skip islands omit the attribute entirely — parse after (and only if) it
49
+ // exists, otherwise parse("{}") would throw "Invalid input" and abort the
50
+ // whole pending-hydration loop
51
+ const rawProps = island.getAttribute("island-props");
52
+ const islandProps = rawProps === null ? [] : parse(rawProps);
49
53
  const islandSrc = island.getAttribute("island-src");
50
54
  const islandEntry = island.getAttribute("island-entry");
51
55
  // oxlint-disable-next-line typescript/no-unsafe-type-assertion