@pwfabric/core 0.0.0-stage → 1.0.0-rc.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 (95) hide show
  1. package/LICENSE +90 -0
  2. package/README.md +13 -2
  3. package/dist/blocks/host-imports.d.ts +128 -0
  4. package/dist/blocks/host-imports.d.ts.map +1 -0
  5. package/dist/blocks/host-imports.js +183 -0
  6. package/dist/blocks/host-imports.js.map +1 -0
  7. package/dist/blocks/index.d.ts +13 -0
  8. package/dist/blocks/index.d.ts.map +1 -0
  9. package/dist/blocks/index.js +18 -0
  10. package/dist/blocks/index.js.map +1 -0
  11. package/dist/blocks/layout-schema.d.ts +354 -0
  12. package/dist/blocks/layout-schema.d.ts.map +1 -0
  13. package/dist/blocks/layout-schema.js +132 -0
  14. package/dist/blocks/layout-schema.js.map +1 -0
  15. package/dist/blocks/types.d.ts +117 -0
  16. package/dist/blocks/types.d.ts.map +1 -0
  17. package/dist/blocks/types.js +39 -0
  18. package/dist/blocks/types.js.map +1 -0
  19. package/dist/capability-builder.d.ts +14 -0
  20. package/dist/capability-builder.d.ts.map +1 -0
  21. package/dist/capability-builder.js +14 -0
  22. package/dist/capability-builder.js.map +1 -0
  23. package/dist/config-schema-builder.d.ts +74 -0
  24. package/dist/config-schema-builder.d.ts.map +1 -0
  25. package/dist/config-schema-builder.js +269 -0
  26. package/dist/config-schema-builder.js.map +1 -0
  27. package/dist/contract-builder.d.ts +70 -0
  28. package/dist/contract-builder.d.ts.map +1 -0
  29. package/dist/contract-builder.js +225 -0
  30. package/dist/contract-builder.js.map +1 -0
  31. package/dist/contracts/passthrough.d.ts +15 -0
  32. package/dist/contracts/passthrough.d.ts.map +1 -0
  33. package/dist/contracts/passthrough.js +23 -0
  34. package/dist/contracts/passthrough.js.map +1 -0
  35. package/dist/errors/AppError.d.ts +85 -0
  36. package/dist/errors/AppError.d.ts.map +1 -0
  37. package/dist/errors/AppError.js +120 -0
  38. package/dist/errors/AppError.js.map +1 -0
  39. package/dist/errors/ErrorCode.d.ts +46 -0
  40. package/dist/errors/ErrorCode.d.ts.map +1 -0
  41. package/dist/errors/ErrorCode.js +88 -0
  42. package/dist/errors/ErrorCode.js.map +1 -0
  43. package/dist/errors/index.d.ts +10 -0
  44. package/dist/errors/index.d.ts.map +1 -0
  45. package/dist/errors/index.js +10 -0
  46. package/dist/errors/index.js.map +1 -0
  47. package/dist/errors.d.ts +38 -0
  48. package/dist/errors.d.ts.map +1 -0
  49. package/dist/errors.js +57 -0
  50. package/dist/errors.js.map +1 -0
  51. package/dist/index.d.ts +25 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +43 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/logger.d.ts +31 -0
  56. package/dist/logger.d.ts.map +1 -0
  57. package/dist/logger.js +67 -0
  58. package/dist/logger.js.map +1 -0
  59. package/dist/monitoring/index.d.ts +10 -0
  60. package/dist/monitoring/index.d.ts.map +1 -0
  61. package/dist/monitoring/index.js +10 -0
  62. package/dist/monitoring/index.js.map +1 -0
  63. package/dist/monitoring/metrics.d.ts +83 -0
  64. package/dist/monitoring/metrics.d.ts.map +1 -0
  65. package/dist/monitoring/metrics.js +55 -0
  66. package/dist/monitoring/metrics.js.map +1 -0
  67. package/dist/monitoring/web-vitals.d.ts +41 -0
  68. package/dist/monitoring/web-vitals.d.ts.map +1 -0
  69. package/dist/monitoring/web-vitals.js +179 -0
  70. package/dist/monitoring/web-vitals.js.map +1 -0
  71. package/dist/oauth-scopes.d.ts +51 -0
  72. package/dist/oauth-scopes.d.ts.map +1 -0
  73. package/dist/oauth-scopes.js +81 -0
  74. package/dist/oauth-scopes.js.map +1 -0
  75. package/dist/observability/index.d.ts +10 -0
  76. package/dist/observability/index.d.ts.map +1 -0
  77. package/dist/observability/index.js +10 -0
  78. package/dist/observability/index.js.map +1 -0
  79. package/dist/observability/logger.d.ts +63 -0
  80. package/dist/observability/logger.d.ts.map +1 -0
  81. package/dist/observability/logger.js +107 -0
  82. package/dist/observability/logger.js.map +1 -0
  83. package/dist/observability/tracer.d.ts +56 -0
  84. package/dist/observability/tracer.d.ts.map +1 -0
  85. package/dist/observability/tracer.js +92 -0
  86. package/dist/observability/tracer.js.map +1 -0
  87. package/dist/state.d.ts +133 -0
  88. package/dist/state.d.ts.map +1 -0
  89. package/dist/state.js +149 -0
  90. package/dist/state.js.map +1 -0
  91. package/dist/utils.d.ts +31 -0
  92. package/dist/utils.d.ts.map +1 -0
  93. package/dist/utils.js +51 -0
  94. package/dist/utils.js.map +1 -0
  95. package/package.json +51 -3
package/LICENSE ADDED
@@ -0,0 +1,90 @@
1
+ Business Source License 1.1
2
+
3
+ Parameters
4
+
5
+ Licensor: PhiMajor Solutions
6
+ Licensed Work: @pwfabric/core 1.0.0
7
+ The Licensed Work is (c) 2026 PhiMajor Solutions.
8
+ Additional Use Grant: You may make production use of the Licensed Work,
9
+ including building applications with it and hosting
10
+ those applications for yourself or for your own
11
+ customers, provided you do not offer the Licensed Work
12
+ to third parties as a hosted or managed service where
13
+ the service gives them substantially the functionality
14
+ of the Licensed Work.
15
+ Change Date: 2030-08-21
16
+ Change License: Apache License, Version 2.0
17
+
18
+ For information about alternative licensing arrangements for the Licensed
19
+ Work, please contact licensing@phimajor.com.
20
+
21
+ Notice
22
+
23
+ Business Source License 1.1
24
+
25
+ Terms
26
+
27
+ The Licensor hereby grants you the right to copy, modify, create derivative
28
+ works, redistribute, and make non-production use of the Licensed Work. The
29
+ Licensor may make an Additional Use Grant, above, permitting limited
30
+ production use.
31
+
32
+ Effective on the Change Date, or the fourth anniversary of the first publicly
33
+ available distribution of a specific version of the Licensed Work under this
34
+ License, whichever comes first, the Licensor hereby grants you rights under
35
+ the terms of the Change License, and the rights granted in the paragraph
36
+ above terminate.
37
+
38
+ If your use of the Licensed Work does not comply with the requirements
39
+ currently in effect as described in this License, you must purchase a
40
+ commercial license from the Licensor, its affiliated entities, or authorized
41
+ resellers, or you must refrain from using the Licensed Work.
42
+
43
+ All copies of the original and modified Licensed Work, and derivative works
44
+ of the Licensed Work, are subject to this License. This License applies
45
+ separately for each version of the Licensed Work and the Change Date may vary
46
+ for each version of the Licensed Work released by Licensor.
47
+
48
+ You must conspicuously display this License on each original or modified copy
49
+ of the Licensed Work. If you receive the Licensed Work in original or
50
+ modified form from a third party, the terms and conditions set forth in this
51
+ License apply to your use of that work.
52
+
53
+ Any use of the Licensed Work in violation of this License will automatically
54
+ terminate your rights under this License for the current and all other
55
+ versions of the Licensed Work.
56
+
57
+ This License does not grant you any right in any trademark or logo of
58
+ Licensor or its affiliates (provided that you may use a trademark or logo of
59
+ Licensor as expressly required by this License).
60
+
61
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
62
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
63
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
64
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
65
+ TITLE.
66
+
67
+ MariaDB hereby grants you permission to use this License's text to license
68
+ your works, and to refer to it using the trademark "Business Source License",
69
+ as long as you comply with the Covenants of Licensor below.
70
+
71
+ Covenants of Licensor
72
+
73
+ In consideration of the right to use this License's text and the "Business
74
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
75
+ other recipients of the licensed work to be provided by Licensor:
76
+
77
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
78
+ or a license that is compatible with GPL Version 2.0 or a later version,
79
+ where "compatible" means that software provided under the Change License
80
+ can be included in a program with software provided under GPL Version 2.0
81
+ or a later version. Licensor may specify additional Change Licenses
82
+ without limitation.
83
+
84
+ 2. To either: (a) specify an additional grant of rights to use that does not
85
+ impose any additional restriction on the right granted in this License, as
86
+ the Additional Use Grant; or (b) insert the text "None".
87
+
88
+ 3. To specify a Change Date.
89
+
90
+ 4. Not to modify this License in any other way.
package/README.md CHANGED
@@ -1,3 +1,14 @@
1
- # Temporary Holding Version
1
+ # @pwfabric/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Primitives the rest of the engine is built from: schemas, results, state, errors.
4
+
5
+ ```bash
6
+ pnpm add @pwfabric/core
7
+ ```
8
+
9
+ Part of [PWFabric](https://github.com/pwfabric/pwfabric). Documentation, the
10
+ other packages and the licensing model live in that repository.
11
+
12
+ ## Licence
13
+
14
+ Business Source License 1.1 — see `LICENSE`. Use it, change it, host what you build with it; do not offer PWFabric itself as a service. Becomes Apache-2.0 on the Change Date.
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Block Host Imports — what a dynamically loaded block may import, and what the
3
+ * host must therefore provide.
4
+ *
5
+ * WHY THIS EXISTS. A published block is bundled per atom with esbuild and
6
+ * loaded in the browser through `<script type="importmap">` + `import(blob:…)`.
7
+ * Two kinds of import survive that: relative paths to files inside the block's
8
+ * own pack, and a short list of BARE specifiers that are left unbundled for the
9
+ * host to supply. That list appears in three places — the bundler's externals,
10
+ * the host's import map and the shim files the host serves — and a specifier
11
+ * missing from any one of them fails at load time ("Failed to resolve module
12
+ * specifier" inside the blob module).
13
+ *
14
+ * This module is that contract, in one place, so the bundler's allowlist, the
15
+ * host's import map and the shim files are all DERIVED and can be checked
16
+ * against each other instead of drifting in silence.
17
+ *
18
+ * WHY NOT IN `@pwfabric/contracts`, where `dynamic-artifact.ts` already lives.
19
+ * The contracts package is treated as immutable after release: every change to
20
+ * its surface, even an additive one, goes through a stricter review. This list has to
21
+ * change whenever a package joins or leaves the allowlist; putting it behind a
22
+ * ceremony is what would recreate the drift it exists to prevent. It lives here,
23
+ * where an additive export is an ordinary minor.
24
+ *
25
+ * @module @pwfabric/core/blocks/host-imports
26
+ */
27
+ /**
28
+ * How the host hands a shared module to a dynamically loaded block.
29
+ *
30
+ * `global` — the shim re-exports from `globalThis[global]`, which the host seeds
31
+ * from its OWN bundled import. This is the mechanism for anything whose IDENTITY
32
+ * must be shared: one React dispatcher, one event bus, one set of contract
33
+ * values. Two instances of these is not "slightly wasteful", it is broken —
34
+ * `useSurfaceEvents` reading a second context makes `emit()` a silent no-op.
35
+ *
36
+ * It is the only kind: every specifier on this list is resolved by the host
37
+ * through a shim reading a global. `zod` included — blocks share the host's
38
+ * single zod instance, because introspection needs the real zod for
39
+ * `instanceof` while walking a schema. A specifier a bundler inlines is simply
40
+ * not external, and so never reaches this list.
41
+ */
42
+ export type HostImportKind = 'global';
43
+ /**
44
+ * WHICH hosts seed a `global` entry. There are two of them and they are not
45
+ * obliged to agree — recording that here keeps a derived gate from calling a
46
+ * deliberate decision a gap.
47
+ *
48
+ * `every-host` — both the app host and the standalone export's IIFE
49
+ * (`@pwfabric/embed`'s `embed-global.ts`) must seed it.
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.
57
+ * `unseeded` — nothing seeds it yet. The specifier resolves (the shim is
58
+ * served) but its named exports come back `undefined`. That is
59
+ * strictly better than an unresolved bare specifier, which
60
+ * fails the whole module at link time — but it is a gap, and
61
+ * naming it here keeps it visible.
62
+ */
63
+ export type HostSeeding = 'every-host' | 'app-host' | 'unseeded';
64
+ /** One specifier a block may import, and how the host satisfies it. */
65
+ export interface HostImport {
66
+ /** The bare specifier as it appears in block source and in the bundle. */
67
+ readonly specifier: string;
68
+ readonly kind: HostImportKind;
69
+ /**
70
+ * The `globalThis` key the shim reads. Present for `kind: 'global'` only.
71
+ * The host seeds it from its own bundled import of the same package.
72
+ */
73
+ readonly global?: string;
74
+ /** Which hosts seed {@link HostImport.global}. Present for `kind: 'global'` only. */
75
+ readonly seeding?: HostSeeding;
76
+ /**
77
+ * Shim file this specifier resolves to, relative to the host's shim directory.
78
+ * SEVERAL SPECIFIERS MAY SHARE ONE FILE — `@pwfabric/runtime` and its
79
+ * subpaths all resolve to the runtime shim, because what a block imports is
80
+ * a runtime contract, not a package name.
81
+ */
82
+ readonly shim: string;
83
+ /** Why this specifier is on the list. Read by humans, not by code. */
84
+ readonly reason: string;
85
+ }
86
+ /**
87
+ * THE LIST. Order is not significant; every consumer derives from the whole set.
88
+ *
89
+ * Adding an entry is the ONLY supported way to let blocks import something new.
90
+ * The derivation helpers below mean a new entry reaches the bundler's allowlist,
91
+ * every host's import map and every shim file together.
92
+ */
93
+ export declare const BLOCK_HOST_IMPORTS: readonly HostImport[];
94
+ /**
95
+ * The specifiers esbuild must leave bare when bundling an atom.
96
+ *
97
+ * A bundling service's externals list is exactly this: the bundler leaves each
98
+ * specifier bare, and the host's import map resolves it to the shared instance.
99
+ */
100
+ export declare function blockBundleExternals(): readonly string[];
101
+ /**
102
+ * The host's `<script type="importmap">` payload.
103
+ *
104
+ * @param shimBase - URL prefix the shim files are served from, no trailing
105
+ * slash (for example `/_pwfabric/shims`).
106
+ */
107
+ export declare function blockImportMap(shimBase: string): {
108
+ readonly imports: Record<string, string>;
109
+ };
110
+ /** Every distinct shim file the import map can point at. */
111
+ export declare function blockShimFiles(): readonly string[];
112
+ /**
113
+ * The `globalThis` keys a host must seed before any block bundle is imported.
114
+ *
115
+ * A host that renders published blocks assigns each of these from its own
116
+ * bundled import. Missing one does not throw where it is missing — it throws
117
+ * inside a block, later, as an undefined named import.
118
+ */
119
+ export declare function blockHostGlobals(host?: 'app-host' | 'standalone'): readonly string[];
120
+ /** Entries whose global nothing seeds yet — a gap this list refuses to hide. */
121
+ export declare function unseededHostGlobals(): readonly HostImport[];
122
+ /**
123
+ * Which specifiers resolve to a given shim file — the reverse of `shim`.
124
+ * A shim generator needs this: one file serves every specifier aliased to it,
125
+ * so it must export the union of what those specifiers' consumers import.
126
+ */
127
+ export declare function specifiersForShim(shim: string): readonly string[];
128
+ //# sourceM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AAS,UAAU,EAAE,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAEjE"}
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Block Host Imports — what a dynamically loaded block may import, and what the
3
+ * host must therefore provide.
4
+ *
5
+ * WHY THIS EXISTS. A published block is bundled per atom with esbuild and
6
+ * loaded in the browser through `<script type="importmap">` + `import(blob:…)`.
7
+ * Two kinds of import survive that: relative paths to files inside the block's
8
+ * own pack, and a short list of BARE specifiers that are left unbundled for the
9
+ * host to supply. That list appears in three places — the bundler's externals,
10
+ * the host's import map and the shim files the host serves — and a specifier
11
+ * missing from any one of them fails at load time ("Failed to resolve module
12
+ * specifier" inside the blob module).
13
+ *
14
+ * This module is that contract, in one place, so the bundler's allowlist, the
15
+ * host's import map and the shim files are all DERIVED and can be checked
16
+ * against each other instead of drifting in silence.
17
+ *
18
+ * WHY NOT IN `@pwfabric/contracts`, where `dynamic-artifact.ts` already lives.
19
+ * The contracts package is treated as immutable after release: every change to
20
+ * its surface, even an additive one, goes through a stricter review. This list has to
21
+ * change whenever a package joins or leaves the allowlist; putting it behind a
22
+ * ceremony is what would recreate the drift it exists to prevent. It lives here,
23
+ * where an additive export is an ordinary minor.
24
+ *
25
+ * @module @pwfabric/core/blocks/host-imports
26
+ */
27
+ /**
28
+ * THE LIST. Order is not significant; every consumer derives from the whole set.
29
+ *
30
+ * Adding an entry is the ONLY supported way to let blocks import something new.
31
+ * The derivation helpers below mean a new entry reaches the bundler's allowlist,
32
+ * every host's import map and every shim file together.
33
+ */
34
+ export const BLOCK_HOST_IMPORTS = [
35
+ {
36
+ specifier: 'react',
37
+ kind: 'global',
38
+ global: '__pwfabric_react',
39
+ seeding: 'every-host',
40
+ shim: 'react.mjs',
41
+ reason: 'One dispatcher. A second React instance makes every hook in a block throw "Cannot read properties of null (reading \'useState\')".',
42
+ },
43
+ {
44
+ specifier: 'react/jsx-runtime',
45
+ kind: 'global',
46
+ global: '__pwfabric_jsx_runtime',
47
+ seeding: 'every-host',
48
+ shim: 'react-jsx-runtime.mjs',
49
+ reason: '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.',
50
+ },
51
+ {
52
+ specifier: 'react-dom',
53
+ kind: 'global',
54
+ global: '__pwfabric_react_dom',
55
+ seeding: 'unseeded',
56
+ shim: 'react-dom.mjs',
57
+ reason: 'Blocks that portal or measure reach for react-dom; same-instance rule as React.',
58
+ },
59
+ {
60
+ specifier: '@pwfabric/runtime',
61
+ kind: 'global',
62
+ global: '__pwfabric_runtime',
63
+ seeding: 'every-host',
64
+ shim: 'runtime.mjs',
65
+ reason: 'Surface event bus, surface id and connections contexts. A block reading a second context emits into nothing.',
66
+ },
67
+ {
68
+ specifier: '@pwfabric/runtime/data',
69
+ kind: 'global',
70
+ global: '__pwfabric_runtime',
71
+ seeding: 'every-host',
72
+ shim: 'runtime.mjs',
73
+ reason: '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.',
74
+ },
75
+ {
76
+ specifier: '@pwfabric/runtime/capability',
77
+ kind: 'global',
78
+ global: '__pwfabric_runtime',
79
+ seeding: 'every-host',
80
+ shim: 'runtime.mjs',
81
+ reason: '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.',
82
+ },
83
+ {
84
+ specifier: '@pwfabric/runtime/adapters',
85
+ kind: 'global',
86
+ global: '__pwfabric_runtime',
87
+ seeding: 'every-host',
88
+ shim: 'runtime.mjs',
89
+ reason: '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.',
90
+ },
91
+ {
92
+ specifier: '@pwfabric/contracts',
93
+ kind: 'global',
94
+ global: '__pwfabric_contracts',
95
+ seeding: 'every-host',
96
+ shim: 'contracts.mjs',
97
+ reason: 'Contract VALUES (enums, constants) must be the host’s, not a second copy.',
98
+ },
99
+ {
100
+ specifier: '@pwfabric/core',
101
+ kind: 'global',
102
+ global: '__pwfabric_core',
103
+ seeding: 'unseeded',
104
+ shim: 'core.mjs',
105
+ reason: 'Block layout helpers and breakpoint constants blocks resolve at render time.',
106
+ },
107
+ {
108
+ specifier: '@pwfabric/authoring',
109
+ kind: 'global',
110
+ global: '__pwfabric_sdk',
111
+ seeding: 'app-host',
112
+ shim: 'sdk@v1.mjs',
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
+ },
115
+ {
116
+ specifier: 'zod',
117
+ kind: 'global',
118
+ global: '__pwfabric_zod',
119
+ seeding: 'every-host',
120
+ shim: 'zod.mjs',
121
+ reason: '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.',
122
+ },
123
+ ];
124
+ // ============================================================
125
+ // DERIVATIONS — every consumer reads the list through one of these
126
+ // ============================================================
127
+ /**
128
+ * The specifiers esbuild must leave bare when bundling an atom.
129
+ *
130
+ * A bundling service's externals list is exactly this: the bundler leaves each
131
+ * specifier bare, and the host's import map resolves it to the shared instance.
132
+ */
133
+ export function blockBundleExternals() {
134
+ return BLOCK_HOST_IMPORTS.map((i) => i.specifier);
135
+ }
136
+ /**
137
+ * The host's `<script type="importmap">` payload.
138
+ *
139
+ * @param shimBase - URL prefix the shim files are served from, no trailing
140
+ * slash (for example `/_pwfabric/shims`).
141
+ */
142
+ export function blockImportMap(shimBase) {
143
+ const imports = {};
144
+ for (const entry of BLOCK_HOST_IMPORTS) {
145
+ imports[entry.specifier] = `${shimBase}/${entry.shim}`;
146
+ }
147
+ return { imports };
148
+ }
149
+ /** Every distinct shim file the import map can point at. */
150
+ export function blockShimFiles() {
151
+ return [...new Set(BLOCK_HOST_IMPORTS.map((i) => i.shim))].sort();
152
+ }
153
+ /**
154
+ * The `globalThis` keys a host must seed before any block bundle is imported.
155
+ *
156
+ * A host that renders published blocks assigns each of these from its own
157
+ * bundled import. Missing one does not throw where it is missing — it throws
158
+ * inside a block, later, as an undefined named import.
159
+ */
160
+ export function blockHostGlobals(host = 'app-host') {
161
+ // The standalone export is NOT the app host with fewer features — it seeds a
162
+ // deliberately smaller set, and asking it for the app host's list would make a
163
+ // gate demand the sdk global it deliberately leaves out. `unseeded`
164
+ // entries belong to neither list: nothing seeds them today, and pretending
165
+ // otherwise would turn a recorded gap into a failing gate nobody can satisfy.
166
+ const wanted = host === 'standalone' ? ['every-host'] : ['every-host', 'app-host'];
167
+ return [
168
+ ...new Set(BLOCK_HOST_IMPORTS.flatMap((i) => i.global && i.seeding && wanted.includes(i.seeding) ? [i.global] : [])),
169
+ ].sort();
170
+ }
171
+ /** Entries whose global nothing seeds yet — a gap this list refuses to hide. */
172
+ export function unseededHostGlobals() {
173
+ return BLOCK_HOST_IMPORTS.filter((i) => i.seeding === 'unseeded');
174
+ }
175
+ /**
176
+ * Which specifiers resolve to a given shim file — the reverse of `shim`.
177
+ * A shim generator needs this: one file serves every specifier aliased to it,
178
+ * so it must export the union of what those specifiers' consumers import.
179
+ */
180
+ export function specifiersForShim(shim) {
181
+ return BLOCK_HOST_IMPORTS.filter((i) => i.shim === shim).map((i) => i.specifier);
182
+ }
183
+ //# sourceMappingURL=host-imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-imports.js","sourceRoot":"","sources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 * Block type definitions, layout schema, and composition rule engine.
5
+ * Block schemas, definitions, and components are in @pwfabric/runtime/blocks.
6
+ *
7
+ * @module @pwfabric/core/blocks
8
+ */
9
+ export type { BlockCategory, BlockDefinition, Block, ValidationError, ValidationResult, CompositionRuleType, CompositionRule, } from './types.js';
10
+ export { MAX_NESTING_DEPTH, BLOCK_CATEGORIES } from './types.js';
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';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EACV,aAAa,EACb,eAAe,EACf,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,GAChB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAGhE,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,gBAAgB,EAChB,KAAK,UAAU,EACf,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oBAAoB,CAAA;AAM3B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Block Ecosystem
3
+ *
4
+ * Block type definitions, layout schema, and composition rule engine.
5
+ * Block schemas, definitions, and components are in @pwfabric/runtime/blocks.
6
+ *
7
+ * @module @pwfabric/core/blocks
8
+ */
9
+ export { MAX_NESTING_DEPTH, BLOCK_CATEGORIES } from './types.js';
10
+ // Layout Schema
11
+ export { BREAKPOINTS, BREAKPOINT_ORDER, DEFAULT_BLOCK_LAYOUT, VIEWPORT_PRESETS, responsiveNumberSchema, responsiveBooleanSchema, responsiveWidthScopeSchema, widthScopeSchema, blockLayoutSchema, resolveResponsiveValue, resolveSpanAtBreakpoint, getColumnsAtBreakpoint, getBreakpointForWidth, } from './layout-schema.js';
12
+ // What a dynamically loaded block may import, and what the host must provide.
13
+ // One list; the bundler's allowlist, every host import map and every shim file
14
+ // are derived from it rather than hand-copied — see the module header for the
15
+ // three-way drift this replaces.
16
+ export { BLOCK_HOST_IMPORTS, blockBundleExternals, blockImportMap, blockShimFiles, blockHostGlobals, unseededHostGlobals, specifiersForShim, } from './host-imports.js';
17
+ // NOTE: CompositionRuleEngine has moved to @pwfabric/runtime/blocks
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}