@pwfabric/core 1.0.0-rc.1 → 1.0.0-rc.2

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.
@@ -48,12 +48,12 @@ export type HostImportKind = 'global';
48
48
  * `every-host` — both the app host and the standalone export's IIFE
49
49
  * (`@pwfabric/embed`'s `embed-global.ts`) must seed it.
50
50
  * `app-host` — the app host seeds it; the standalone export deliberately
51
- * does NOT. The sdk global is the standing case: the authoring
52
- * kit is a development-time surface and does not belong in a
53
- * shipped app export, even though a published block's compiled
54
- * bundle may still call `defineBlock()` at module-load time.
55
- * Such a block works in the live canvas and degrades in a
56
- * standalone export, which is the chosen trade-off.
51
+ * does NOT. No entry is in this class today. The sdk global
52
+ * was, until 1.0.0-rc.2: a block written the documented way
53
+ * calls `defineBlock()` when its bundle loads, so a shipped
54
+ * app whose page did not seed the sdk rendered none of them.
55
+ * The renderer bundle carries the authoring kit anyway, so it
56
+ * now seeds it like the rest.
57
57
  * `unseeded` — nothing seeds it yet. The specifier resolves (the shim is
58
58
  * served) but its named exports come back `undefined`. That is
59
59
  * strictly better than an unresolved bare specifier, which
@@ -125,3 +125,24 @@ export declare function unseededHostGlobals(): readonly HostImport[];
125
125
  * so it must export the union of what those specifiers' consumers import.
126
126
  */
127
127
  export declare function specifiersForShim(shim: string): readonly string[];
128
+ /** Whether `name` can be an `export const { name }` binding in a shim module. */
129
+ export declare function isExportableName(name: string): boolean;
130
+ /**
131
+ * Source of one shim module: it re-exports the instance a host seeded on
132
+ * `globalThis[global]`, as a default export and as one named export per entry
133
+ * of `names` that can be a binding (see {@link isExportableName}), deduplicated
134
+ * and sorted. `shim` is a file from {@link blockShimFiles}; the header comment
135
+ * lists the specifiers that resolve to it.
136
+ *
137
+ * Every host serving block bundles writes these files; the names are the
138
+ * host's to supply (an ESM import of a name the shim does not export fails the
139
+ * whole block at link time, so they should be read off the very object the host
140
+ * seeds).
141
+ *
142
+ * A shim whose global every host must seed (`seeding: 'every-host'`) throws a
143
+ * readable error when the global is missing, naming the global and the
144
+ * specifiers: the alternative is a destructuring `TypeError` inside a blob
145
+ * module, which says nothing about the host that forgot to seed it. A shim for
146
+ * an `unseeded` global keeps degrading to `undefined` exports instead.
147
+ */
148
+ export declare function shimSource(shim: string, global: string, names: readonly string[]): string;
@@ -108,7 +108,7 @@ export const BLOCK_HOST_IMPORTS = [
108
108
  specifier: '@pwfabric/authoring',
109
109
  kind: 'global',
110
110
  global: '__pwfabric_sdk',
111
- seeding: 'app-host',
111
+ seeding: 'every-host',
112
112
  shim: 'sdk@v1.mjs',
113
113
  reason: 'What the scaffolding emits and a third-party author reads first. A host that does not map it breaks every block that follows the documented path.',
114
114
  },
@@ -180,4 +180,61 @@ export function unseededHostGlobals() {
180
180
  export function specifiersForShim(shim) {
181
181
  return BLOCK_HOST_IMPORTS.filter((i) => i.shim === shim).map((i) => i.specifier);
182
182
  }
183
+ /**
184
+ * Names a shim must not bind even though they parse as identifiers.
185
+ *
186
+ * Reserved words fail the parse outright. `undefined`, `NaN` and `Infinity`
187
+ * are global value properties: `export const { undefined } = m` parses, but
188
+ * it shadows a restricted name (lint refuses it, and some toolchains refuse to
189
+ * parse it), and no block imports them by name. zod exports `undefined` (its
190
+ * `z.undefined()` schema), so a shim built from zod's keys would carry it.
191
+ */
192
+ const NON_BINDABLE_NAMES = new Set(('break case catch class const continue debugger default delete do else enum export extends false finally for ' +
193
+ 'function if import in instanceof new null return super switch this throw true try typeof var void while with ' +
194
+ 'yield let static implements interface package private protected public await arguments eval ' +
195
+ 'undefined NaN Infinity').split(' '));
196
+ /** Whether `name` can be an `export const { name }` binding in a shim module. */
197
+ export function isExportableName(name) {
198
+ return /^[A-Za-z_$][\w$]*$/.test(name) && !NON_BINDABLE_NAMES.has(name);
199
+ }
200
+ /**
201
+ * Source of one shim module: it re-exports the instance a host seeded on
202
+ * `globalThis[global]`, as a default export and as one named export per entry
203
+ * of `names` that can be a binding (see {@link isExportableName}), deduplicated
204
+ * and sorted. `shim` is a file from {@link blockShimFiles}; the header comment
205
+ * lists the specifiers that resolve to it.
206
+ *
207
+ * Every host serving block bundles writes these files; the names are the
208
+ * host's to supply (an ESM import of a name the shim does not export fails the
209
+ * whole block at link time, so they should be read off the very object the host
210
+ * seeds).
211
+ *
212
+ * A shim whose global every host must seed (`seeding: 'every-host'`) throws a
213
+ * readable error when the global is missing, naming the global and the
214
+ * specifiers: the alternative is a destructuring `TypeError` inside a blob
215
+ * module, which says nothing about the host that forgot to seed it. A shim for
216
+ * an `unseeded` global keeps degrading to `undefined` exports instead.
217
+ */
218
+ export function shimSource(shim, global, names) {
219
+ const exported = [...new Set(names)].filter(isExportableName).sort();
220
+ const specifiers = specifiersForShim(shim);
221
+ const required = BLOCK_HOST_IMPORTS.some((i) => i.shim === shim && i.seeding === 'every-host');
222
+ const served = specifiers.map((s) => `'${s}'`).join(', ');
223
+ const lines = [
224
+ `// Generated by pwf. Serves ${served} to compiled blocks:`,
225
+ `// re-exports the instance the page seeded on globalThis.${global}.`,
226
+ ];
227
+ if (required) {
228
+ const message = `[pwfabric] globalThis.${global} is not seeded, so ${specifiers.join(', ') || shim} cannot be imported by a block. The host page must seed it before loading block bundles (@pwfabric/embed's embed.js does).`;
229
+ lines.push(`const m = globalThis.${global}`, `if (m == null) throw new Error(${JSON.stringify(message)})`);
230
+ }
231
+ else {
232
+ lines.push(`const m = globalThis.${global} ?? {}`);
233
+ }
234
+ lines.push('export default m');
235
+ if (exported.length > 0) {
236
+ lines.push(`export const {\n${exported.map((n) => ` ${n},`).join('\n')}\n} = m`);
237
+ }
238
+ return `${lines.join('\n')}\n`;
239
+ }
183
240
  //# sourceMappingURL=host-imports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"host-imports.js","sourceRoot":"","sources":["../../src/blocks/host-imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAoEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA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,CAAC,CAAC,IAAI,EAAE,CAAA;AACnE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAkC,UAAU;IAC3E,6EAA6E;IAC7E,+EAA+E;IAC/E,oEAAoE;IACpE,2EAA2E;IAC3E,8EAA8E;IAC9E,MAAM,MAAM,GACV,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;IACrE,OAAO;QACL,GAAG,IAAI,GAAG,CACR,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/B,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CACtE,CACF;KACF,CAAC,IAAI,EAAE,CAAA;AACV,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,mBAAmB;IACjC,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,CAAA;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;AAClF,CAAC","sourcesContent":["/**\n * Block Host Imports — what a dynamically loaded block may import, and what the\n * host must therefore provide.\n *\n * WHY THIS EXISTS. A published block is bundled per atom with esbuild and\n * loaded in the browser through `<script type=\"importmap\">` + `import(blob:…)`.\n * Two kinds of import survive that: relative paths to files inside the block's\n * own pack, and a short list of BARE specifiers that are left unbundled for the\n * host to supply. That list appears in three places — the bundler's externals,\n * the host's import map and the shim files the host serves — and a specifier\n * missing from any one of them fails at load time (\"Failed to resolve module\n * specifier\" inside the blob module).\n *\n * This module is that contract, in one place, so the bundler's allowlist, the\n * host's import map and the shim files are all DERIVED and can be checked\n * against each other instead of drifting in silence.\n *\n * WHY NOT IN `@pwfabric/contracts`, where `dynamic-artifact.ts` already lives.\n * The contracts package is treated as immutable after release: every change to\n * its surface, even an additive one, goes through a stricter review. This list has to\n * change whenever a package joins or leaves the allowlist; putting it behind a\n * ceremony is what would recreate the drift it exists to prevent. It lives here,\n * where an additive export is an ordinary minor.\n *\n * @module @pwfabric/core/blocks/host-imports\n */\n\n// ============================================================\n// THE CONTRACT\n// ============================================================\n\n/**\n * How the host hands a shared module to a dynamically loaded block.\n *\n * `global` — the shim re-exports from `globalThis[global]`, which the host seeds\n * from its OWN bundled import. This is the mechanism for anything whose IDENTITY\n * must be shared: one React dispatcher, one event bus, one set of contract\n * values. Two instances of these is not \"slightly wasteful\", it is broken —\n * `useSurfaceEvents` reading a second context makes `emit()` a silent no-op.\n *\n * It is the only kind: every specifier on this list is resolved by the host\n * through a shim reading a global. `zod` included — blocks share the host's\n * single zod instance, because introspection needs the real zod for\n * `instanceof` while walking a schema. A specifier a bundler inlines is simply\n * not external, and so never reaches this list.\n */\nexport type HostImportKind = 'global'\n\n/**\n * WHICH hosts seed a `global` entry. There are two of them and they are not\n * obliged to agree — recording that here keeps a derived gate from calling a\n * deliberate decision a gap.\n *\n * `every-host` — both the app host and the standalone export's IIFE\n * (`@pwfabric/embed`'s `embed-global.ts`) must seed it.\n * `app-host` — the app host seeds it; the standalone export deliberately\n * does NOT. The sdk global is the standing case: the authoring\n * kit is a development-time surface and does not belong in a\n * shipped app export, even though a published block's compiled\n * bundle may still call `defineBlock()` at module-load time.\n * Such a block works in the live canvas and degrades in a\n * standalone export, which is the chosen trade-off.\n * `unseeded` — nothing seeds it yet. The specifier resolves (the shim is\n * served) but its named exports come back `undefined`. That is\n * strictly better than an unresolved bare specifier, which\n * fails the whole module at link time — but it is a gap, and\n * naming it here keeps it visible.\n */\nexport type HostSeeding = 'every-host' | 'app-host' | 'unseeded'\n\n/** One specifier a block may import, and how the host satisfies it. */\nexport interface HostImport {\n /** The bare specifier as it appears in block source and in the bundle. */\n readonly specifier: string\n readonly kind: HostImportKind\n /**\n * The `globalThis` key the shim reads. Present for `kind: 'global'` only.\n * The host seeds it from its own bundled import of the same package.\n */\n readonly global?: string\n /** Which hosts seed {@link HostImport.global}. Present for `kind: 'global'` only. */\n readonly seeding?: HostSeeding\n /**\n * Shim file this specifier resolves to, relative to the host's shim directory.\n * SEVERAL SPECIFIERS MAY SHARE ONE FILE — `@pwfabric/runtime` and its\n * subpaths all resolve to the runtime shim, because what a block imports is\n * a runtime contract, not a package name.\n */\n readonly shim: string\n /** Why this specifier is on the list. Read by humans, not by code. */\n readonly reason: string\n}\n\n/**\n * THE LIST. Order is not significant; every consumer derives from the whole set.\n *\n * Adding an entry is the ONLY supported way to let blocks import something new.\n * The derivation helpers below mean a new entry reaches the bundler's allowlist,\n * every host's import map and every shim file together.\n */\nexport const BLOCK_HOST_IMPORTS: readonly HostImport[] = [\n {\n specifier: 'react',\n kind: 'global',\n global: '__pwfabric_react',\n seeding: 'every-host',\n shim: 'react.mjs',\n reason:\n 'One dispatcher. A second React instance makes every hook in a block throw \"Cannot read properties of null (reading \\'useState\\')\".',\n },\n {\n specifier: 'react/jsx-runtime',\n kind: 'global',\n global: '__pwfabric_jsx_runtime',\n seeding: 'every-host',\n shim: 'react-jsx-runtime.mjs',\n reason:\n 'The automatic JSX transform emits imports from here; it must be the same React. NOTE the global is `__pwfabric_jsx_runtime`, not `…_react_jsx_runtime`; the shim and the seeders read this name.',\n },\n {\n specifier: 'react-dom',\n kind: 'global',\n global: '__pwfabric_react_dom',\n seeding: 'unseeded',\n shim: 'react-dom.mjs',\n reason: 'Blocks that portal or measure reach for react-dom; same-instance rule as React.',\n },\n {\n specifier: '@pwfabric/runtime',\n kind: 'global',\n global: '__pwfabric_runtime',\n seeding: 'every-host',\n shim: 'runtime.mjs',\n reason:\n 'Surface event bus, surface id and connections contexts. A block reading a second context emits into nothing.',\n },\n {\n specifier: '@pwfabric/runtime/data',\n kind: 'global',\n global: '__pwfabric_runtime',\n seeding: 'every-host',\n shim: 'runtime.mjs',\n reason:\n 'A runtime subpath the package root re-exports WHOLESALE, so the root shim serves it exactly — the foundation pack persistence capability imports `createDataService` from here. An import map resolves exact specifiers only: without this entry the import would compile with a HOST_SUBPATH_IMPORT warning and then fail to resolve in the browser. Only subpaths whose every export the root also exports may join; the runtime package has a test that says so.',\n },\n {\n specifier: '@pwfabric/runtime/capability',\n kind: 'global',\n global: '__pwfabric_runtime',\n seeding: 'every-host',\n shim: 'runtime.mjs',\n reason:\n 'A runtime subpath the package root re-exports WHOLESALE, so the root shim serves it exactly — capability atoms import their definition helpers from here. An import map resolves exact specifiers only: without this entry the import would compile with a HOST_SUBPATH_IMPORT warning and then fail to resolve in the browser. Only subpaths whose every export the root also exports may join; the runtime package has a test that says so.',\n },\n {\n specifier: '@pwfabric/runtime/adapters',\n kind: 'global',\n global: '__pwfabric_runtime',\n seeding: 'every-host',\n shim: 'runtime.mjs',\n reason:\n 'A runtime subpath the package root re-exports WHOLESALE, so the root shim serves it exactly — image adapters; a block that renders a responsive image reaches for them here. An import map resolves exact specifiers only: without this entry the import would compile with a HOST_SUBPATH_IMPORT warning and then fail to resolve in the browser. Only subpaths whose every export the root also exports may join; the runtime package has a test that says so.',\n },\n {\n specifier: '@pwfabric/contracts',\n kind: 'global',\n global: '__pwfabric_contracts',\n seeding: 'every-host',\n shim: 'contracts.mjs',\n reason: 'Contract VALUES (enums, constants) must be the host’s, not a second copy.',\n },\n {\n specifier: '@pwfabric/core',\n kind: 'global',\n global: '__pwfabric_core',\n seeding: 'unseeded',\n shim: 'core.mjs',\n reason: 'Block layout helpers and breakpoint constants blocks resolve at render time.',\n },\n {\n specifier: '@pwfabric/authoring',\n kind: 'global',\n global: '__pwfabric_sdk',\n seeding: 'app-host',\n shim: 'sdk@v1.mjs',\n reason:\n 'What the scaffolding emits and a third-party author reads first. A host that does not map it breaks every block that follows the documented path.',\n },\n {\n specifier: 'zod',\n kind: 'global',\n global: '__pwfabric_zod',\n seeding: 'every-host',\n shim: 'zod.mjs',\n reason:\n 'Every block with a prop schema imports it as a value — 81 pack source files take `z`. Shared, not inlined: `zod.mjs` re-exports the host instance, and introspection depends on it being the real zod so `instanceof` holds while walking a schema.',\n },\n] as const\n\n// ============================================================\n// DERIVATIONS — every consumer reads the list through one of these\n// ============================================================\n\n/**\n * The specifiers esbuild must leave bare when bundling an atom.\n *\n * A bundling service's externals list is exactly this: the bundler leaves each\n * specifier bare, and the host's import map resolves it to the shared instance.\n */\nexport function blockBundleExternals(): readonly string[] {\n return BLOCK_HOST_IMPORTS.map((i) => i.specifier)\n}\n\n/**\n * The host's `<script type=\"importmap\">` payload.\n *\n * @param shimBase - URL prefix the shim files are served from, no trailing\n * slash (for example `/_pwfabric/shims`).\n */\nexport function blockImportMap(shimBase: string): { readonly imports: Record<string, string> } {\n const imports: Record<string, string> = {}\n for (const entry of BLOCK_HOST_IMPORTS) {\n imports[entry.specifier] = `${shimBase}/${entry.shim}`\n }\n return { imports }\n}\n\n/** Every distinct shim file the import map can point at. */\nexport function blockShimFiles(): readonly string[] {\n return [...new Set(BLOCK_HOST_IMPORTS.map((i) => i.shim))].sort()\n}\n\n/**\n * The `globalThis` keys a host must seed before any block bundle is imported.\n *\n * A host that renders published blocks assigns each of these from its own\n * bundled import. Missing one does not throw where it is missing — it throws\n * inside a block, later, as an undefined named import.\n */\nexport function blockHostGlobals(host: 'app-host' | 'standalone' = 'app-host'): readonly string[] {\n // The standalone export is NOT the app host with fewer features — it seeds a\n // deliberately smaller set, and asking it for the app host's list would make a\n // gate demand the sdk global it deliberately leaves out. `unseeded`\n // entries belong to neither list: nothing seeds them today, and pretending\n // otherwise would turn a recorded gap into a failing gate nobody can satisfy.\n const wanted: readonly HostSeeding[] =\n host === 'standalone' ? ['every-host'] : ['every-host', 'app-host']\n return [\n ...new Set(\n BLOCK_HOST_IMPORTS.flatMap((i) =>\n i.global && i.seeding && wanted.includes(i.seeding) ? [i.global] : []\n )\n ),\n ].sort()\n}\n\n/** Entries whose global nothing seeds yet — a gap this list refuses to hide. */\nexport function unseededHostGlobals(): readonly HostImport[] {\n return BLOCK_HOST_IMPORTS.filter((i) => i.seeding === 'unseeded')\n}\n\n/**\n * Which specifiers resolve to a given shim file — the reverse of `shim`.\n * A shim generator needs this: one file serves every specifier aliased to it,\n * so it must export the union of what those specifiers' consumers import.\n */\nexport function specifiersForShim(shim: string): readonly string[] {\n return BLOCK_HOST_IMPORTS.filter((i) => i.shim === shim).map((i) => i.specifier)\n}\n"]}
1
+ {"version":3,"file":"host-imports.js","sourceRoot":"","sources":["../../src/blocks/host-imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAoEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA0B;IACvD;QACE,SAAS,EAAE,OAAO;QAClB,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,kBAAkB;QAC1B,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,WAAW;QACjB,MAAM,EACJ,oIAAoI;KACvI;IACD;QACE,SAAS,EAAE,mBAAmB;QAC9B,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,wBAAwB;QAChC,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EACJ,kMAAkM;KACrM;IACD;QACE,SAAS,EAAE,WAAW;QACtB,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,sBAAsB;QAC9B,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,iFAAiF;KAC1F;IACD;QACE,SAAS,EAAE,mBAAmB;QAC9B,IAAI,EAAE,QA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IAAI,CAAC,CAAC,OAAO,KAAK,YAAY,CAAC,CAAA;IAC9F,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzD,MAAM,KAAK,GAAG;QACZ,+BAA+B,MAAM,sBAAsB;QAC3D,4DAA4D,MAAM,GAAG;KACtE,CAAA;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,yBAAyB,MAAM,sBAAsB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,4HAA4H,CAAA;QAC9N,KAAK,CAAC,IAAI,CACR,wBAAwB,MAAM,EAAE,EAChC,kCAAkC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAC7D,CAAA;IACH,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC,wBAAwB,MAAM,QAAQ,CAAC,CAAA;IACpD,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IAC9B,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,mBAAmB,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACnF,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;AAChC,CAAC","sourcesContent":["/**\n * Block Host Imports — what a dynamically loaded block may import, and what the\n * host must therefore provide.\n *\n * WHY THIS EXISTS. A published block is bundled per atom with esbuild and\n * loaded in the browser through `<script type=\"importmap\">` + `import(blob:…)`.\n * Two kinds of import survive that: relative paths to files inside the block's\n * own pack, and a short list of BARE specifiers that are left unbundled for the\n * host to supply. That list appears in three places — the bundler's externals,\n * the host's import map and the shim files the host serves — and a specifier\n * missing from any one of them fails at load time (\"Failed to resolve module\n * specifier\" inside the blob module).\n *\n * This module is that contract, in one place, so the bundler's allowlist, the\n * host's import map and the shim files are all DERIVED and can be checked\n * against each other instead of drifting in silence.\n *\n * WHY NOT IN `@pwfabric/contracts`, where `dynamic-artifact.ts` already lives.\n * The contracts package is treated as immutable after release: every change to\n * its surface, even an additive one, goes through a stricter review. This list has to\n * change whenever a package joins or leaves the allowlist; putting it behind a\n * ceremony is what would recreate the drift it exists to prevent. It lives here,\n * where an additive export is an ordinary minor.\n *\n * @module @pwfabric/core/blocks/host-imports\n */\n\n// ============================================================\n// THE CONTRACT\n// ============================================================\n\n/**\n * How the host hands a shared module to a dynamically loaded block.\n *\n * `global` — the shim re-exports from `globalThis[global]`, which the host seeds\n * from its OWN bundled import. This is the mechanism for anything whose IDENTITY\n * must be shared: one React dispatcher, one event bus, one set of contract\n * values. Two instances of these is not \"slightly wasteful\", it is broken —\n * `useSurfaceEvents` reading a second context makes `emit()` a silent no-op.\n *\n * It is the only kind: every specifier on this list is resolved by the host\n * through a shim reading a global. `zod` included — blocks share the host's\n * single zod instance, because introspection needs the real zod for\n * `instanceof` while walking a schema. A specifier a bundler inlines is simply\n * not external, and so never reaches this list.\n */\nexport type HostImportKind = 'global'\n\n/**\n * WHICH hosts seed a `global` entry. There are two of them and they are not\n * obliged to agree — recording that here keeps a derived gate from calling a\n * deliberate decision a gap.\n *\n * `every-host` — both the app host and the standalone export's IIFE\n * (`@pwfabric/embed`'s `embed-global.ts`) must seed it.\n * `app-host` — the app host seeds it; the standalone export deliberately\n * does NOT. No entry is in this class today. The sdk global\n * was, until 1.0.0-rc.2: a block written the documented way\n * calls `defineBlock()` when its bundle loads, so a shipped\n * app whose page did not seed the sdk rendered none of them.\n * The renderer bundle carries the authoring kit anyway, so it\n * now seeds it like the rest.\n * `unseeded` — nothing seeds it yet. The specifier resolves (the shim is\n * served) but its named exports come back `undefined`. That is\n * strictly better than an unresolved bare specifier, which\n * fails the whole module at link time — but it is a gap, and\n * naming it here keeps it visible.\n */\nexport type HostSeeding = 'every-host' | 'app-host' | 'unseeded'\n\n/** One specifier a block may import, and how the host satisfies it. */\nexport interface HostImport {\n /** The bare specifier as it appears in block source and in the bundle. */\n readonly specifier: string\n readonly kind: HostImportKind\n /**\n * The `globalThis` key the shim reads. Present for `kind: 'global'` only.\n * The host seeds it from its own bundled import of the same package.\n */\n readonly global?: string\n /** Which hosts seed {@link HostImport.global}. Present for `kind: 'global'` only. */\n readonly seeding?: HostSeeding\n /**\n * Shim file this specifier resolves to, relative to the host's shim directory.\n * SEVERAL SPECIFIERS MAY SHARE ONE FILE — `@pwfabric/runtime` and its\n * subpaths all resolve to the runtime shim, because what a block imports is\n * a runtime contract, not a package name.\n */\n readonly shim: string\n /** Why this specifier is on the list. Read by humans, not by code. */\n readonly reason: string\n}\n\n/**\n * THE LIST. Order is not significant; every consumer derives from the whole set.\n *\n * Adding an entry is the ONLY supported way to let blocks import something new.\n * The derivation helpers below mean a new entry reaches the bundler's allowlist,\n * every host's import map and every shim file together.\n */\nexport const BLOCK_HOST_IMPORTS: readonly HostImport[] = [\n {\n specifier: 'react',\n kind: 'global',\n global: '__pwfabric_react',\n seeding: 'every-host',\n shim: 'react.mjs',\n reason:\n 'One dispatcher. A second React instance makes every hook in a block throw \"Cannot read properties of null (reading \\'useState\\')\".',\n },\n {\n specifier: 'react/jsx-runtime',\n kind: 'global',\n global: '__pwfabric_jsx_runtime',\n seeding: 'every-host',\n shim: 'react-jsx-runtime.mjs',\n reason:\n 'The automatic JSX transform emits imports from here; it must be the same React. NOTE the global is `__pwfabric_jsx_runtime`, not `…_react_jsx_runtime`; the shim and the seeders read this name.',\n },\n {\n specifier: 'react-dom',\n kind: 'global',\n global: '__pwfabric_react_dom',\n seeding: 'unseeded',\n shim: 'react-dom.mjs',\n reason: 'Blocks that portal or measure reach for react-dom; same-instance rule as React.',\n },\n {\n specifier: '@pwfabric/runtime',\n kind: 'global',\n global: '__pwfabric_runtime',\n seeding: 'every-host',\n shim: 'runtime.mjs',\n reason:\n 'Surface event bus, surface id and connections contexts. A block reading a second context emits into nothing.',\n },\n {\n specifier: '@pwfabric/runtime/data',\n kind: 'global',\n global: '__pwfabric_runtime',\n seeding: 'every-host',\n shim: 'runtime.mjs',\n reason:\n 'A runtime subpath the package root re-exports WHOLESALE, so the root shim serves it exactly — the foundation pack persistence capability imports `createDataService` from here. An import map resolves exact specifiers only: without this entry the import would compile with a HOST_SUBPATH_IMPORT warning and then fail to resolve in the browser. Only subpaths whose every export the root also exports may join; the runtime package has a test that says so.',\n },\n {\n specifier: '@pwfabric/runtime/capability',\n kind: 'global',\n global: '__pwfabric_runtime',\n seeding: 'every-host',\n shim: 'runtime.mjs',\n reason:\n 'A runtime subpath the package root re-exports WHOLESALE, so the root shim serves it exactly — capability atoms import their definition helpers from here. An import map resolves exact specifiers only: without this entry the import would compile with a HOST_SUBPATH_IMPORT warning and then fail to resolve in the browser. Only subpaths whose every export the root also exports may join; the runtime package has a test that says so.',\n },\n {\n specifier: '@pwfabric/runtime/adapters',\n kind: 'global',\n global: '__pwfabric_runtime',\n seeding: 'every-host',\n shim: 'runtime.mjs',\n reason:\n 'A runtime subpath the package root re-exports WHOLESALE, so the root shim serves it exactly — image adapters; a block that renders a responsive image reaches for them here. An import map resolves exact specifiers only: without this entry the import would compile with a HOST_SUBPATH_IMPORT warning and then fail to resolve in the browser. Only subpaths whose every export the root also exports may join; the runtime package has a test that says so.',\n },\n {\n specifier: '@pwfabric/contracts',\n kind: 'global',\n global: '__pwfabric_contracts',\n seeding: 'every-host',\n shim: 'contracts.mjs',\n reason: 'Contract VALUES (enums, constants) must be the host’s, not a second copy.',\n },\n {\n specifier: '@pwfabric/core',\n kind: 'global',\n global: '__pwfabric_core',\n seeding: 'unseeded',\n shim: 'core.mjs',\n reason: 'Block layout helpers and breakpoint constants blocks resolve at render time.',\n },\n {\n specifier: '@pwfabric/authoring',\n kind: 'global',\n global: '__pwfabric_sdk',\n seeding: 'every-host',\n shim: 'sdk@v1.mjs',\n reason:\n 'What the scaffolding emits and a third-party author reads first. A host that does not map it breaks every block that follows the documented path.',\n },\n {\n specifier: 'zod',\n kind: 'global',\n global: '__pwfabric_zod',\n seeding: 'every-host',\n shim: 'zod.mjs',\n reason:\n 'Every block with a prop schema imports it as a value — 81 pack source files take `z`. Shared, not inlined: `zod.mjs` re-exports the host instance, and introspection depends on it being the real zod so `instanceof` holds while walking a schema.',\n },\n] as const\n\n// ============================================================\n// DERIVATIONS — every consumer reads the list through one of these\n// ============================================================\n\n/**\n * The specifiers esbuild must leave bare when bundling an atom.\n *\n * A bundling service's externals list is exactly this: the bundler leaves each\n * specifier bare, and the host's import map resolves it to the shared instance.\n */\nexport function blockBundleExternals(): readonly string[] {\n return BLOCK_HOST_IMPORTS.map((i) => i.specifier)\n}\n\n/**\n * The host's `<script type=\"importmap\">` payload.\n *\n * @param shimBase - URL prefix the shim files are served from, no trailing\n * slash (for example `/_pwfabric/shims`).\n */\nexport function blockImportMap(shimBase: string): { readonly imports: Record<string, string> } {\n const imports: Record<string, string> = {}\n for (const entry of BLOCK_HOST_IMPORTS) {\n imports[entry.specifier] = `${shimBase}/${entry.shim}`\n }\n return { imports }\n}\n\n/** Every distinct shim file the import map can point at. */\nexport function blockShimFiles(): readonly string[] {\n return [...new Set(BLOCK_HOST_IMPORTS.map((i) => i.shim))].sort()\n}\n\n/**\n * The `globalThis` keys a host must seed before any block bundle is imported.\n *\n * A host that renders published blocks assigns each of these from its own\n * bundled import. Missing one does not throw where it is missing — it throws\n * inside a block, later, as an undefined named import.\n */\nexport function blockHostGlobals(host: 'app-host' | 'standalone' = 'app-host'): readonly string[] {\n // The standalone export is NOT the app host with fewer features — it seeds a\n // deliberately smaller set, and asking it for the app host's list would make a\n // gate demand the sdk global it deliberately leaves out. `unseeded`\n // entries belong to neither list: nothing seeds them today, and pretending\n // otherwise would turn a recorded gap into a failing gate nobody can satisfy.\n const wanted: readonly HostSeeding[] =\n host === 'standalone' ? ['every-host'] : ['every-host', 'app-host']\n return [\n ...new Set(\n BLOCK_HOST_IMPORTS.flatMap((i) =>\n i.global && i.seeding && wanted.includes(i.seeding) ? [i.global] : []\n )\n ),\n ].sort()\n}\n\n/** Entries whose global nothing seeds yet — a gap this list refuses to hide. */\nexport function unseededHostGlobals(): readonly HostImport[] {\n return BLOCK_HOST_IMPORTS.filter((i) => i.seeding === 'unseeded')\n}\n\n/**\n * Which specifiers resolve to a given shim file — the reverse of `shim`.\n * A shim generator needs this: one file serves every specifier aliased to it,\n * so it must export the union of what those specifiers' consumers import.\n */\nexport function specifiersForShim(shim: string): readonly string[] {\n return BLOCK_HOST_IMPORTS.filter((i) => i.shim === shim).map((i) => i.specifier)\n}\n\n/**\n * Names a shim must not bind even though they parse as identifiers.\n *\n * Reserved words fail the parse outright. `undefined`, `NaN` and `Infinity`\n * are global value properties: `export const { undefined } = m` parses, but\n * it shadows a restricted name (lint refuses it, and some toolchains refuse to\n * parse it), and no block imports them by name. zod exports `undefined` (its\n * `z.undefined()` schema), so a shim built from zod's keys would carry it.\n */\nconst NON_BINDABLE_NAMES = new Set(\n (\n 'break case catch class const continue debugger default delete do else enum export extends false finally for ' +\n 'function if import in instanceof new null return super switch this throw true try typeof var void while with ' +\n 'yield let static implements interface package private protected public await arguments eval ' +\n 'undefined NaN Infinity'\n ).split(' ')\n)\n\n/** Whether `name` can be an `export const { name }` binding in a shim module. */\nexport function isExportableName(name: string): boolean {\n return /^[A-Za-z_$][\\w$]*$/.test(name) && !NON_BINDABLE_NAMES.has(name)\n}\n\n/**\n * Source of one shim module: it re-exports the instance a host seeded on\n * `globalThis[global]`, as a default export and as one named export per entry\n * of `names` that can be a binding (see {@link isExportableName}), deduplicated\n * and sorted. `shim` is a file from {@link blockShimFiles}; the header comment\n * lists the specifiers that resolve to it.\n *\n * Every host serving block bundles writes these files; the names are the\n * host's to supply (an ESM import of a name the shim does not export fails the\n * whole block at link time, so they should be read off the very object the host\n * seeds).\n *\n * A shim whose global every host must seed (`seeding: 'every-host'`) throws a\n * readable error when the global is missing, naming the global and the\n * specifiers: the alternative is a destructuring `TypeError` inside a blob\n * module, which says nothing about the host that forgot to seed it. A shim for\n * an `unseeded` global keeps degrading to `undefined` exports instead.\n */\nexport function shimSource(shim: string, global: string, names: readonly string[]): string {\n const exported = [...new Set(names)].filter(isExportableName).sort()\n const specifiers = specifiersForShim(shim)\n const required = BLOCK_HOST_IMPORTS.some((i) => i.shim === shim && i.seeding === 'every-host')\n const served = specifiers.map((s) => `'${s}'`).join(', ')\n const lines = [\n `// Generated by pwf. Serves ${served} to compiled blocks:`,\n `// re-exports the instance the page seeded on globalThis.${global}.`,\n ]\n if (required) {\n const message = `[pwfabric] globalThis.${global} is not seeded, so ${specifiers.join(', ') || shim} cannot be imported by a block. The host page must seed it before loading block bundles (@pwfabric/embed's embed.js does).`\n lines.push(\n `const m = globalThis.${global}`,\n `if (m == null) throw new Error(${JSON.stringify(message)})`\n )\n } else {\n lines.push(`const m = globalThis.${global} ?? {}`)\n }\n lines.push('export default m')\n if (exported.length > 0) {\n lines.push(`export const {\\n${exported.map((n) => ` ${n},`).join('\\n')}\\n} = m`)\n }\n return `${lines.join('\\n')}\\n`\n}\n"]}
@@ -9,4 +9,4 @@
9
9
  export type { BlockCategory, BlockDefinition, Block, ValidationError, ValidationResult, CompositionRuleType, CompositionRule, } from './types.js';
10
10
  export { MAX_NESTING_DEPTH, BLOCK_CATEGORIES } from './types.js';
11
11
  export { type BreakpointName, type BreakpointDefinition, type ResponsiveValue, type BlockLayout, type PreviewViewport, BREAKPOINTS, BREAKPOINT_ORDER, DEFAULT_BLOCK_LAYOUT, VIEWPORT_PRESETS, responsiveNumberSchema, responsiveBooleanSchema, responsiveWidthScopeSchema, widthScopeSchema, type WidthScope, blockLayoutSchema, resolveResponsiveValue, resolveSpanAtBreakpoint, getColumnsAtBreakpoint, getBreakpointForWidth, } from './layout-schema.js';
12
- export { BLOCK_HOST_IMPORTS, blockBundleExternals, blockImportMap, blockShimFiles, blockHostGlobals, unseededHostGlobals, specifiersForShim, type HostImport, type HostImportKind, type HostSeeding, } from './host-imports.js';
12
+ export { BLOCK_HOST_IMPORTS, blockBundleExternals, blockImportMap, blockShimFiles, blockHostGlobals, unseededHostGlobals, specifiersForShim, isExportableName, shimSource, type HostImport, type HostImportKind, type HostSeeding, } from './host-imports.js';
@@ -13,6 +13,6 @@ export { BREAKPOINTS, BREAKPOINT_ORDER, DEFAULT_BLOCK_LAYOUT, VIEWPORT_PRESETS,
13
13
  // One list; the bundler's allowlist, every host import map and every shim file
14
14
  // are derived from it rather than hand-copied — see the module header for the
15
15
  // three-way drift this replaces.
16
- export { BLOCK_HOST_IMPORTS, blockBundleExternals, blockImportMap, blockShimFiles, blockHostGlobals, unseededHostGlobals, specifiersForShim, } from './host-imports.js';
16
+ export { BLOCK_HOST_IMPORTS, blockBundleExternals, blockImportMap, blockShimFiles, blockHostGlobals, unseededHostGlobals, specifiersForShim, isExportableName, shimSource, } from './host-imports.js';
17
17
  // NOTE: CompositionRuleEngine has moved to @pwfabric/runtime/blocks
18
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAaH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEhE,gBAAgB;AAChB,OAAO,EAML,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,gBAAgB,EAEhB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oBAAoB,CAAA;AAE3B,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,iCAAiC;AACjC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GAIlB,MAAM,mBAAmB,CAAA;AAE1B,oEAAoE","sourcesContent":["/**\n * Block Ecosystem\n *\n * Block type definitions, layout schema, and composition rule engine.\n * Block schemas, definitions, and components are in @pwfabric/runtime/blocks.\n *\n * @module @pwfabric/core/blocks\n */\n\n// Types (remain in core — used by @pwfabric/runtime/blocks as peer types)\nexport type {\n BlockCategory,\n BlockDefinition,\n Block,\n ValidationError,\n ValidationResult,\n CompositionRuleType,\n CompositionRule,\n} from './types.js'\n\nexport { MAX_NESTING_DEPTH, BLOCK_CATEGORIES } from './types.js'\n\n// Layout Schema\nexport {\n type BreakpointName,\n type BreakpointDefinition,\n type ResponsiveValue,\n type BlockLayout,\n type PreviewViewport,\n BREAKPOINTS,\n BREAKPOINT_ORDER,\n DEFAULT_BLOCK_LAYOUT,\n VIEWPORT_PRESETS,\n responsiveNumberSchema,\n responsiveBooleanSchema,\n responsiveWidthScopeSchema,\n widthScopeSchema,\n type WidthScope,\n blockLayoutSchema,\n resolveResponsiveValue,\n resolveSpanAtBreakpoint,\n getColumnsAtBreakpoint,\n getBreakpointForWidth,\n} from './layout-schema.js'\n\n// What a dynamically loaded block may import, and what the host must provide.\n// One list; the bundler's allowlist, every host import map and every shim file\n// are derived from it rather than hand-copied — see the module header for the\n// three-way drift this replaces.\nexport {\n BLOCK_HOST_IMPORTS,\n blockBundleExternals,\n blockImportMap,\n blockShimFiles,\n blockHostGlobals,\n unseededHostGlobals,\n specifiersForShim,\n type HostImport,\n type HostImportKind,\n type HostSeeding,\n} from './host-imports.js'\n\n// NOTE: CompositionRuleEngine has moved to @pwfabric/runtime/blocks\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAaH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEhE,gBAAgB;AAChB,OAAO,EAML,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,gBAAgB,EAEhB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oBAAoB,CAAA;AAE3B,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,iCAAiC;AACjC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,GAIX,MAAM,mBAAmB,CAAA;AAE1B,oEAAoE","sourcesContent":["/**\n * Block Ecosystem\n *\n * Block type definitions, layout schema, and composition rule engine.\n * Block schemas, definitions, and components are in @pwfabric/runtime/blocks.\n *\n * @module @pwfabric/core/blocks\n */\n\n// Types (remain in core — used by @pwfabric/runtime/blocks as peer types)\nexport type {\n BlockCategory,\n BlockDefinition,\n Block,\n ValidationError,\n ValidationResult,\n CompositionRuleType,\n CompositionRule,\n} from './types.js'\n\nexport { MAX_NESTING_DEPTH, BLOCK_CATEGORIES } from './types.js'\n\n// Layout Schema\nexport {\n type BreakpointName,\n type BreakpointDefinition,\n type ResponsiveValue,\n type BlockLayout,\n type PreviewViewport,\n BREAKPOINTS,\n BREAKPOINT_ORDER,\n DEFAULT_BLOCK_LAYOUT,\n VIEWPORT_PRESETS,\n responsiveNumberSchema,\n responsiveBooleanSchema,\n responsiveWidthScopeSchema,\n widthScopeSchema,\n type WidthScope,\n blockLayoutSchema,\n resolveResponsiveValue,\n resolveSpanAtBreakpoint,\n getColumnsAtBreakpoint,\n getBreakpointForWidth,\n} from './layout-schema.js'\n\n// What a dynamically loaded block may import, and what the host must provide.\n// One list; the bundler's allowlist, every host import map and every shim file\n// are derived from it rather than hand-copied — see the module header for the\n// three-way drift this replaces.\nexport {\n BLOCK_HOST_IMPORTS,\n blockBundleExternals,\n blockImportMap,\n blockShimFiles,\n blockHostGlobals,\n unseededHostGlobals,\n specifiersForShim,\n isExportableName,\n shimSource,\n type HostImport,\n type HostImportKind,\n type HostSeeding,\n} from './host-imports.js'\n\n// NOTE: CompositionRuleEngine has moved to @pwfabric/runtime/blocks\n"]}
package/dist/index.d.ts CHANGED
@@ -21,4 +21,4 @@ export { isScopeToken, readScopeList, type ScopeListReading } from './oauth-scop
21
21
  export { CapabilityBuilder, defineCapability } from './capability-builder.js';
22
22
  export { FieldBuilder, ConfigSchemaBuilder, SimpleConfigSchema, defineConfigSchema, } from './config-schema-builder.js';
23
23
  export { type StateStore, type StateListener, type StateSnapshot, type Selector, type Transition, type StateMachineConfig, type StateMachine, SimpleStateStore, SimpleStateMachine, createStateStore, computed, subscribeToSlice, createStateMachine, } from './state.js';
24
- export { type BlockCategory, type BlockDefinition, type Block, type ValidationError as BlockValidationError, type ValidationResult as BlockValidationResult, type CompositionRuleType, type CompositionRule, MAX_NESTING_DEPTH, BLOCK_CATEGORIES, type BreakpointName, type BreakpointDefinition, type ResponsiveValue, type BlockLayout, type PreviewViewport, BREAKPOINTS, BREAKPOINT_ORDER, DEFAULT_BLOCK_LAYOUT, VIEWPORT_PRESETS, responsiveNumberSchema, responsiveBooleanSchema, blockLayoutSchema, resolveResponsiveValue, resolveSpanAtBreakpoint, getColumnsAtBreakpoint, getBreakpointForWidth, BLOCK_HOST_IMPORTS, blockBundleExternals, blockImportMap, blockShimFiles, blockHostGlobals, unseededHostGlobals, specifiersForShim, type HostImport, type HostImportKind, type HostSeeding, } from './blocks/index.js';
24
+ export { type BlockCategory, type BlockDefinition, type Block, type ValidationError as BlockValidationError, type ValidationResult as BlockValidationResult, type CompositionRuleType, type CompositionRule, MAX_NESTING_DEPTH, BLOCK_CATEGORIES, type BreakpointName, type BreakpointDefinition, type ResponsiveValue, type BlockLayout, type PreviewViewport, BREAKPOINTS, BREAKPOINT_ORDER, DEFAULT_BLOCK_LAYOUT, VIEWPORT_PRESETS, responsiveNumberSchema, responsiveBooleanSchema, blockLayoutSchema, resolveResponsiveValue, resolveSpanAtBreakpoint, getColumnsAtBreakpoint, getBreakpointForWidth, BLOCK_HOST_IMPORTS, blockBundleExternals, blockImportMap, blockShimFiles, blockHostGlobals, unseededHostGlobals, specifiersForShim, isExportableName, shimSource, type HostImport, type HostImportKind, type HostSeeding, } from './blocks/index.js';
package/dist/index.js CHANGED
@@ -39,5 +39,5 @@ export { SimpleStateStore, SimpleStateMachine, createStateStore, computed, subsc
39
39
  export { MAX_NESTING_DEPTH, BLOCK_CATEGORIES, BREAKPOINTS, BREAKPOINT_ORDER, DEFAULT_BLOCK_LAYOUT, VIEWPORT_PRESETS, responsiveNumberSchema, responsiveBooleanSchema, blockLayoutSchema, resolveResponsiveValue, resolveSpanAtBreakpoint, getColumnsAtBreakpoint, getBreakpointForWidth,
40
40
  // Block host imports — the one list the bundler, the host import maps and the
41
41
  // shim files all derive from.
42
- BLOCK_HOST_IMPORTS, blockBundleExternals, blockImportMap, blockShimFiles, blockHostGlobals, unseededHostGlobals, specifiersForShim, } from './blocks/index.js';
42
+ BLOCK_HOST_IMPORTS, blockBundleExternals, blockImportMap, blockShimFiles, blockHostGlobals, unseededHostGlobals, specifiersForShim, isExportableName, shimSource, } from './blocks/index.js';
43
43
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,sCAAsC;AACtC,cAAc,qBAAqB,CAAA;AAEnC,sDAAsD;AACtD,OAAO,EACL,aAAa,EACb,eAAe,IAAI,mBAAmB,EACtC,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAgC,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEhF,uBAAuB;AACvB,OAAO,EACL,SAAS,EAET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BAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB;AACrB,8EAA8E;AAC9E,8BAA8B;AAC9B,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GAIlB,MAAM,mBAAmB,CAAA","sourcesContent":["/**\n * @pwfabric/core\n *\n * Core functionality and utilities for the PWFabric platform.\n *\n * PHASE0-WS3: Core orchestration layer\n * Platform hardening (errors, monitoring, observability)\n *\n * @module @pwfabric/core\n */\n\n// Re-export contracts for convenience\nexport * from '@pwfabric/contracts'\n\n// Core exports - explicitly exclude conflicting names\nexport {\n PWFabricError,\n ValidationError as CoreValidationError,\n NotFoundError,\n UnauthorizedError,\n ForbiddenError,\n} from './errors.js'\n\nexport { type LogLevel, type LogEntry, Logger, createLogger } from './logger.js'\n\n// Error infrastructure\nexport {\n ErrorCode,\n type ErrorCodeType,\n getHttpStatus,\n isRetryable,\n AppError,\n ValidationAppError,\n NetworkAppError,\n EditorAppError,\n type ErrorContext,\n type SerializedError,\n} from './errors/index.js'\n\n// Monitoring infrastructure\nexport {\n type WebVitalName,\n type MetricRating,\n type Metric,\n type WebVitalMetric,\n type TimingMetric,\n type RenderMetric,\n type PerformanceBudget,\n type MetricsState,\n DEFAULT_BUDGET,\n createMetricsState,\n getRating,\n type WebVitalCallback,\n observeLCP,\n observeFID,\n observeCLS,\n observeTTFB,\n observeINP,\n observeFCP,\n observeAllWebVitals,\n} from './monitoring/index.js'\n\n// Observability infrastructure\nexport {\n type LogContext,\n type ILogger,\n ConsoleLogger,\n createObservabilityLogger,\n type TraceContext,\n type Span,\n type SpanResult,\n createTraceContext,\n createChildContext,\n createSpan,\n extractTraceId,\n injectTraceId,\n} from './observability/index.js'\n\nexport {\n // ok and err are already exported from contracts\n sleep,\n retry,\n generateId,\n} from './utils.js'\n\n// Builders (PHASE0-WS3)\nexport { ContractBuilder, defineContract, anySchema, objectSchema } from './contract-builder.js'\n\n// Canonical contracts\nexport { passthroughContract } from './contracts/passthrough.js'\n\n// Delegated OAuth scope lists — the ONE reader. Three copies of a\n// tolerant reader once split a JSON string into scope-shaped garbage and sent\n// it to Microsoft; consumers import this instead of remembering the rule.\nexport { isScopeToken, readScopeList, type ScopeListReading } from './oauth-scopes.js'\n\nexport { CapabilityBuilder, defineCapability } from './capability-builder.js'\n\nexport {\n FieldBuilder,\n ConfigSchemaBuilder,\n SimpleConfigSchema,\n defineConfigSchema,\n} from './config-schema-builder.js'\n\n// State management (PHASE0-WS3)\nexport {\n type StateStore,\n type StateListener,\n type StateSnapshot,\n type Selector,\n type Transition,\n type StateMachineConfig,\n type StateMachine,\n SimpleStateStore,\n SimpleStateMachine,\n createStateStore,\n computed,\n subscribeToSlice,\n createStateMachine,\n} from './state.js'\n\n// Block ecosystem types and layout schema\n// Block schemas, definitions, rule engine, and React components are in @pwfabric/runtime/blocks (retired standalone package)\nexport {\n // Types\n type BlockCategory,\n type BlockDefinition,\n type Block,\n type ValidationError as BlockValidationError,\n type ValidationResult as BlockValidationResult,\n type CompositionRuleType,\n type CompositionRule,\n MAX_NESTING_DEPTH,\n BLOCK_CATEGORIES,\n // Layout schema\n type BreakpointName,\n type BreakpointDefinition,\n type ResponsiveValue,\n type BlockLayout,\n type PreviewViewport,\n BREAKPOINTS,\n BREAKPOINT_ORDER,\n DEFAULT_BLOCK_LAYOUT,\n VIEWPORT_PRESETS,\n responsiveNumberSchema,\n responsiveBooleanSchema,\n blockLayoutSchema,\n resolveResponsiveValue,\n resolveSpanAtBreakpoint,\n getColumnsAtBreakpoint,\n getBreakpointForWidth,\n // Block host imports — the one list the bundler, the host import maps and the\n // shim files all derive from.\n BLOCK_HOST_IMPORTS,\n blockBundleExternals,\n blockImportMap,\n blockShimFiles,\n blockHostGlobals,\n unseededHostGlobals,\n specifiersForShim,\n type HostImport,\n type HostImportKind,\n type HostSeeding,\n} from './blocks/index.js'\n"]}
1
+ {"version":3,"file":"index.js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AkB,GACnB,MAAM,4BAA4B,CAAA;AAEnC,gCAAgC;AAChC,OAAO,EAQL,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,YAAY,CAAA;AAEnB,0CAA0C;AAC1C,6HAA6H;AAC7H,OAAO,EASL,iBAAiB,EACjB,gBAAgB,EAOhB,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB;AACrB,8EAA8E;AAC9E,8BAA8B;AAC9B,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,GAIX,MAAM,mBAAmB,CAAA","sourcesContent":["/**\n * @pwfabric/core\n *\n * Core functionality and utilities for the PWFabric platform.\n *\n * PHASE0-WS3: Core orchestration layer\n * Platform hardening (errors, monitoring, observability)\n *\n * @module @pwfabric/core\n */\n\n// Re-export contracts for convenience\nexport * from '@pwfabric/contracts'\n\n// Core exports - explicitly exclude conflicting names\nexport {\n PWFabricError,\n ValidationError as CoreValidationError,\n NotFoundError,\n UnauthorizedError,\n ForbiddenError,\n} from './errors.js'\n\nexport { type LogLevel, type LogEntry, Logger, createLogger } from './logger.js'\n\n// Error infrastructure\nexport {\n ErrorCode,\n type ErrorCodeType,\n getHttpStatus,\n isRetryable,\n AppError,\n ValidationAppError,\n NetworkAppError,\n EditorAppError,\n type ErrorContext,\n type SerializedError,\n} from './errors/index.js'\n\n// Monitoring infrastructure\nexport {\n type WebVitalName,\n type MetricRating,\n type Metric,\n type WebVitalMetric,\n type TimingMetric,\n type RenderMetric,\n type PerformanceBudget,\n type MetricsState,\n DEFAULT_BUDGET,\n createMetricsState,\n getRating,\n type WebVitalCallback,\n observeLCP,\n observeFID,\n observeCLS,\n observeTTFB,\n observeINP,\n observeFCP,\n observeAllWebVitals,\n} from './monitoring/index.js'\n\n// Observability infrastructure\nexport {\n type LogContext,\n type ILogger,\n ConsoleLogger,\n createObservabilityLogger,\n type TraceContext,\n type Span,\n type SpanResult,\n createTraceContext,\n createChildContext,\n createSpan,\n extractTraceId,\n injectTraceId,\n} from './observability/index.js'\n\nexport {\n // ok and err are already exported from contracts\n sleep,\n retry,\n generateId,\n} from './utils.js'\n\n// Builders (PHASE0-WS3)\nexport { ContractBuilder, defineContract, anySchema, objectSchema } from './contract-builder.js'\n\n// Canonical contracts\nexport { passthroughContract } from './contracts/passthrough.js'\n\n// Delegated OAuth scope lists — the ONE reader. Three copies of a\n// tolerant reader once split a JSON string into scope-shaped garbage and sent\n// it to Microsoft; consumers import this instead of remembering the rule.\nexport { isScopeToken, readScopeList, type ScopeListReading } from './oauth-scopes.js'\n\nexport { CapabilityBuilder, defineCapability } from './capability-builder.js'\n\nexport {\n FieldBuilder,\n ConfigSchemaBuilder,\n SimpleConfigSchema,\n defineConfigSchema,\n} from './config-schema-builder.js'\n\n// State management (PHASE0-WS3)\nexport {\n type StateStore,\n type StateListener,\n type StateSnapshot,\n type Selector,\n type Transition,\n type StateMachineConfig,\n type StateMachine,\n SimpleStateStore,\n SimpleStateMachine,\n createStateStore,\n computed,\n subscribeToSlice,\n createStateMachine,\n} from './state.js'\n\n// Block ecosystem types and layout schema\n// Block schemas, definitions, rule engine, and React components are in @pwfabric/runtime/blocks (retired standalone package)\nexport {\n // Types\n type BlockCategory,\n type BlockDefinition,\n type Block,\n type ValidationError as BlockValidationError,\n type ValidationResult as BlockValidationResult,\n type CompositionRuleType,\n type CompositionRule,\n MAX_NESTING_DEPTH,\n BLOCK_CATEGORIES,\n // Layout schema\n type BreakpointName,\n type BreakpointDefinition,\n type ResponsiveValue,\n type BlockLayout,\n type PreviewViewport,\n BREAKPOINTS,\n BREAKPOINT_ORDER,\n DEFAULT_BLOCK_LAYOUT,\n VIEWPORT_PRESETS,\n responsiveNumberSchema,\n responsiveBooleanSchema,\n blockLayoutSchema,\n resolveResponsiveValue,\n resolveSpanAtBreakpoint,\n getColumnsAtBreakpoint,\n getBreakpointForWidth,\n // Block host imports — the one list the bundler, the host import maps and the\n // shim files all derive from.\n BLOCK_HOST_IMPORTS,\n blockBundleExternals,\n blockImportMap,\n blockShimFiles,\n blockHostGlobals,\n unseededHostGlobals,\n specifiersForShim,\n isExportableName,\n shimSource,\n type HostImport,\n type HostImportKind,\n type HostSeeding,\n} from './blocks/index.js'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pwfabric/core",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.2",
4
4
  "description": "PWFabric core functionality and utilities",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",
@@ -32,7 +32,7 @@
32
32
  "node": ">=22"
33
33
  },
34
34
  "dependencies": {
35
- "@pwfabric/contracts": "1.0.0-rc.1"
35
+ "@pwfabric/contracts": "1.0.0-rc.2"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "zod": "^3.23.0"