@ogygia/core 0.11.0 → 0.11.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.
@@ -142,6 +142,11 @@ export declare class CompileCtx {
142
142
  constructor(init: CompileCtxInit);
143
143
  /** True when `code` carries an ogygia `with { … }` island hint (gates node_modules `.svelte`). */
144
144
  has_island_hint(code: string): boolean;
145
+ /** True when a JS module has a real `import … with { <mark key>: … }` declaration. The hint
146
+ * above is a text sniff, so it also matches a comment, a string or generated code that merely
147
+ * mentions `with { wake }`; this parses. A module that does not parse counts as marked, so a
148
+ * warning that depends on it errs toward speaking. */
149
+ has_marked_import(code: string, id: string): boolean;
145
150
  /** True when `id` is inside a dependency's DECLARED `ogygia.files` surface — those files are
146
151
  * prescanned + transformed exactly like app source (the node_modules gates lift for them). */
147
152
  in_declared_pkg(id: string): boolean;
@@ -1,6 +1,7 @@
1
1
  import { fs } from "./host.js";
2
2
  import { strip_bom } from "./bom.js";
3
3
  import { islandVirtualId } from "./ids.js";
4
+ import { parse_module } from "./parse/oxc.js";
4
5
  import { islandChunkFileName, islandPublicUrl, wrapperVirtualId } from "./region/transform.js";
5
6
  // src/compiler/ctx.ts
6
7
  /**
@@ -55,6 +56,8 @@ var CompileCtx = class {
55
56
  /** `with { … }` hint matcher — a node_modules `.svelte` is only transformed when it carries one
56
57
  * (so a library can declare its own islands). Built once from the resolved import keys. */
57
58
  #island_hint_re;
59
+ /** The resolved import-attribute keys that make a mark (`wake`, `render`, …). */
60
+ #mark_keys;
58
61
  /** Declared package files (exact) + dirs (prefix) — the transform-gate membership index. */
59
62
  #pkg_files;
60
63
  #pkg_dirs;
@@ -99,6 +102,7 @@ var CompileCtx = class {
99
102
  this.devtools = init.devtools;
100
103
  const hint_keys = Object.values(init.import_keys).filter((v) => typeof v === "string");
101
104
  this.#island_hint_re = hint_keys.length ? new RegExp(`\\bwith\\s*\\{[^}]*\\b(?:${hint_keys.join("|")})\\b`) : NEVER_MATCH_RE;
105
+ this.#mark_keys = new Set(hint_keys);
102
106
  this.#pkg_files = new Set(this.pkg_scan.flatMap((p) => p.files));
103
107
  this.#pkg_dirs = this.pkg_scan.flatMap((p) => p.dirs);
104
108
  this.#pkg_roots = this.pkg_scan.map((p) => ({
@@ -110,6 +114,22 @@ var CompileCtx = class {
110
114
  has_island_hint(code) {
111
115
  return this.#island_hint_re.test(code);
112
116
  }
117
+ /** True when a JS module has a real `import … with { <mark key>: … }` declaration. The hint
118
+ * above is a text sniff, so it also matches a comment, a string or generated code that merely
119
+ * mentions `with { wake }`; this parses. A module that does not parse counts as marked, so a
120
+ * warning that depends on it errs toward speaking. */
121
+ has_marked_import(code, id) {
122
+ const { program, ok } = parse_module(code, id);
123
+ if (!ok || !program) return true;
124
+ for (const node of program.body) {
125
+ if (node.type !== "ImportDeclaration") continue;
126
+ for (const attr of node.attributes ?? []) {
127
+ const key = attr.key?.type === "Identifier" ? attr.key.name : attr.key?.value;
128
+ if (typeof key === "string" && this.#mark_keys.has(key)) return true;
129
+ }
130
+ }
131
+ return false;
132
+ }
113
133
  /** True when `id` is inside a dependency's DECLARED `ogygia.files` surface — those files are
114
134
  * prescanned + transformed exactly like app source (the node_modules gates lift for them). */
115
135
  in_declared_pkg(id) {
@@ -1199,7 +1199,7 @@ var Compiler = class {
1199
1199
  }
1200
1200
  }
1201
1201
  const nm_ts = id_n.endsWith(".ts") || id_n.endsWith(".js") || id_n.endsWith(".mjs") ? id_n.includes("/node_modules/") : null;
1202
- if (nm_ts === true && !id_n.startsWith(ctx.pkg_root) && !ctx.in_declared_pkg(id_n) && ctx.has_island_hint(out)) warn_undeclared_pkg_marks(id_n);
1202
+ if (nm_ts === true && !id_n.startsWith(ctx.pkg_root) && !ctx.in_declared_pkg(id_n) && ctx.has_island_hint(out) && ctx.has_marked_import(out, id_n)) warn_undeclared_pkg_marks(id_n);
1203
1203
  if (nm_ts !== null && (nm_ts === false || ctx.in_declared_pkg(id_n)) && !is_island_path(id_n)) {
1204
1204
  const result = this.ts_regions(out, id_n);
1205
1205
  if (result) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogygia/core",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "The core of ogygia (SSR islands for SvelteKit): apps install `ogygia`, plugins build on this",
5
5
  "homepage": "https://ogygiajs.dev",
6
6
  "bugs": {