Skip to content

Commit 8a2b321

Browse files
janechuCopilot
andcommitted
Restrict fast-element path exports
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 651c412 commit 8a2b321

411 files changed

Lines changed: 9250 additions & 13531 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/skills/typescript/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ both the initial shadow root template and the `<f-template>`:
146146
tracked by templates. `@volatile` marks getters whose dependencies change between calls:
147147

148148
```ts
149-
import { FASTElement } from "@microsoft/fast-element";
149+
import { FASTElement } from "@microsoft/fast-element/fast-element.js";
150150
import { attr, nullableNumberConverter } from "@microsoft/fast-element/attr.js";
151151
import { Observable, observable } from "@microsoft/fast-element/observable.js";
152152
import { volatile } from "@microsoft/fast-element/volatile.js";

examples/todo-app/src/todo-form.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { customElement, FASTElement } from "@microsoft/fast-element";
1+
import { customElement, FASTElement } from "@microsoft/fast-element/fast-element.js";
22
import { observable } from "@microsoft/fast-element/observable.js";
33
import { styles } from "./todo-form.styles.js";
44
import { template } from "./todo-form.template.js";

packages/fast-element/DECLARATIVE_DESIGN.md

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ An optional layer that uses the `Schema` to automatically:
116116
- Propagate deep property mutations back through FAST's observable system so bindings re-render.
117117

118118
Enabled via the `observerMap()` definition extension exported from
119-
`@microsoft/fast-element`. Calling `observerMap()` without arguments observes
120-
all root properties discovered in the template or supplied schema.
119+
`@microsoft/fast-element/observer-map.js`. Calling `observerMap()` without
120+
arguments observes all root properties discovered in the template or supplied
121+
schema.
121122

122123
#### Path-level observation control
123124

@@ -161,9 +162,8 @@ are observed.
161162
For non-declarative elements, pass a schema directly to `observerMap()`:
162163

163164
```typescript
164-
import { FASTElement } from "@microsoft/fast-element";
165-
import { Schema } from "@microsoft/fast-element";
166-
import { observerMap } from "@microsoft/fast-element";
165+
import { FASTElement, Schema } from "@microsoft/fast-element";
166+
import { observerMap } from "@microsoft/fast-element/observer-map.js";
167167

168168
class MyElement extends FASTElement {}
169169

@@ -199,11 +199,11 @@ An optional layer that uses the `Schema` to automatically register `@attr`-style
199199
- `FASTElementDefinition.attributeLookup` is keyed by the HTML attribute name, and `propertyLookup` is keyed by the JS property name so `attributeChangedCallback` correctly delegates to the new `AttributeDefinition`.
200200

201201
Enabled via the `attributeMap()` definition extension exported from
202-
`@microsoft/fast-element`. Calling `attributeMap()` without arguments uses the
203-
default `"camelCase"` strategy. To preserve binding keys exactly as written,
204-
pass `attributeMap({ "attribute-name-strategy": "none" })`. Outside declarative
205-
templates, `attributeMap()` uses the optional `schema` on the FAST element
206-
definition.
202+
`@microsoft/fast-element/attribute-map.js`. Calling `attributeMap()` without
203+
arguments uses the default `"camelCase"` strategy. To preserve binding keys
204+
exactly as written, pass `attributeMap({ "attribute-name-strategy": "none" })`.
205+
Outside declarative templates, `attributeMap()` uses the optional `schema` on the
206+
FAST element definition.
207207

208208
### Syntax constants (`syntax.ts`)
209209

@@ -275,42 +275,48 @@ Schema transforms run in deterministic order. `attributeMap()` runs before
275275
import {
276276
declarativeTemplate,
277277
TemplateParser,
278+
type ResolvedStringsAndValues,
279+
} from "@microsoft/fast-element/declarative.js";
280+
import {
278281
Schema,
279282
schemaRegistry,
280283
type CachedPathMap,
281-
type FASTElementExtension,
282284
type JSONSchema,
283-
type ResolvedStringsAndValues,
285+
} from "@microsoft/fast-element/schema.js";
286+
import {
287+
type FASTElementExtension,
284288
type TemplateLifecycleCallbacks,
289+
} from "@microsoft/fast-element";
290+
import {
285291
attributeMap,
286292
type AttributeMapConfig,
293+
} from "@microsoft/fast-element/attribute-map.js";
294+
import {
287295
observerMap,
288296
type ObserverMapConfig,
289297
type ObserverMapPathEntry,
290298
type ObserverMapPathNode,
291-
} from "@microsoft/fast-element";
299+
} from "@microsoft/fast-element/observer-map.js";
292300
```
293301

294-
The root entrypoint exports the declarative template helpers, map helpers, and
295-
their configuration types. Focused path exports are also available for direct
296-
entrypoint imports.
302+
Declarative template helpers, map helpers, and their configuration types are
303+
available from focused path exports.
297304

298-
Primary exports from `@microsoft/fast-element` intended for
299-
application code:
305+
Primary declarative exports intended for application code:
300306

301307
| Export | Purpose |
302308
|---|---|
303-
| `declarativeTemplate()` | Template resolver for `FASTElement.define()`; auto-defines the internal `<f-template>` publisher and waits for the matching template. |
304-
| `TemplateParser` | Standalone parser that converts declarative HTML into `ViewTemplate` strings/values. Can be used independently of `<f-template>` for programmatic template compilation. |
305-
| `Schema` | JSON schema builder that records binding paths discovered during template parsing. Each instance owns its own schema map and registers itself in the `schemaRegistry` for cross-element `$ref` resolution. |
306-
| `schemaRegistry` | Module-level `Map<string, Map<string, JSONSchema>>` that indexes schemas by custom element name. Used for cross-element lookups (e.g. nested component `$ref` resolution). |
309+
| `declarativeTemplate()` | `@microsoft/fast-element/declarative.js` template resolver for `FASTElement.define()`; auto-defines the internal `<f-template>` publisher and waits for the matching template. |
310+
| `TemplateParser` | `@microsoft/fast-element/declarative.js` standalone parser that converts declarative HTML into `ViewTemplate` strings/values. Can be used independently of `<f-template>` for programmatic template compilation. |
311+
| `Schema` | `@microsoft/fast-element/schema.js` JSON schema builder that records binding paths discovered during template parsing. Each instance owns its own schema map and registers itself in the `schemaRegistry` for cross-element `$ref` resolution. |
312+
| `schemaRegistry` | `@microsoft/fast-element/schema.js` module-level `Map<string, Map<string, JSONSchema>>` that indexes schemas by custom element name. Used for cross-element lookups (e.g. nested component `$ref` resolution). |
307313

308314
Primary map extension exports:
309315

310316
| Export | Import path | Purpose |
311317
|---|---|---|
312-
| `attributeMap()` | `@microsoft/fast-element` | Define extension that registers `@attr`-style properties for leaf bindings discovered during parsing or supplied by `definition.schema`. |
313-
| `observerMap()` | `@microsoft/fast-element` | Define extension that defines observable root properties and proxy-based deep change tracking from `config.schema`, `definition.schema`, or a declarative template schema. |
318+
| `attributeMap()` | `@microsoft/fast-element/attribute-map.js` | Define extension that registers `@attr`-style properties for leaf bindings discovered during parsing or supplied by `definition.schema`. |
319+
| `observerMap()` | `@microsoft/fast-element/observer-map.js` | Define extension that defines observable root properties and proxy-based deep change tracking from `config.schema`, `definition.schema`, or a declarative template schema. |
314320

315321
The implementation element class (`<f-template>`), `TemplateElement.config()`,
316322
`TemplateElement.options()`, `ElementOptions*`, and
@@ -329,14 +335,14 @@ Additionally, `@microsoft/fast-element` exports these types:
329335
| `JSONSchema` | `components/schema.ts` | JSON Schema interface used by `Schema` for property structure. |
330336
| `CachedPathMap` | `components/schema.ts` | `Map<string, Map<string, JSONSchema>>` — the shape of the schema registry. |
331337

332-
The root entrypoint exports the map configuration types:
338+
The map configuration types are exported from the same map-specific paths:
333339

334340
| Type | Import path | Purpose |
335341
|---|---|---|
336-
| `ObserverMapConfig` | `@microsoft/fast-element` | Configuration object for `observerMap()`; accepts optional `schema` and `properties` keys. |
337-
| `ObserverMapPathEntry` | `@microsoft/fast-element` | `boolean \| ObserverMapPathNode` — a node in the observation path tree. |
338-
| `ObserverMapPathNode` | `@microsoft/fast-element` | Object node with optional `$observe` and child property overrides. |
339-
| `AttributeMapConfig` | `@microsoft/fast-element` | Configuration object for `attributeMap()`; accepts `attribute-name-strategy`. |
342+
| `ObserverMapConfig` | `@microsoft/fast-element/observer-map.js` | Configuration object for `observerMap()`; accepts optional `schema` and `properties` keys. |
343+
| `ObserverMapPathEntry` | `@microsoft/fast-element/observer-map.js` | `boolean \| ObserverMapPathNode` — a node in the observation path tree. |
344+
| `ObserverMapPathNode` | `@microsoft/fast-element/observer-map.js` | Object node with optional `$observe` and child property overrides. |
345+
| `AttributeMapConfig` | `@microsoft/fast-element/attribute-map.js` | Configuration object for `attributeMap()`; accepts `attribute-name-strategy`. |
340346

341347
---
342348

packages/fast-element/DECLARATIVE_HTML.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Hydration is opt-in. Call `enableHydration()` before FAST elements connect when
7676
you want prerendered Declarative Shadow DOM to be reused:
7777

7878
```typescript
79-
import { enableHydration } from "@microsoft/fast-element";
79+
import { enableHydration } from "@microsoft/fast-element/hydration.js";
8080

8181
enableHydration({
8282
hydrationStarted() {
@@ -91,7 +91,7 @@ enableHydration({
9191
Pass per-element lifecycle callbacks directly to `declarativeTemplate()`:
9292

9393
```typescript
94-
import { declarativeTemplate } from "@microsoft/fast-element";
94+
import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
9595

9696
MyComponent.define({
9797
name: "my-component",
@@ -140,7 +140,7 @@ For non-declarative/manual schemas, import from `@microsoft/fast-element` and
140140
pass `observerMap({ schema })`.
141141

142142
```typescript
143-
import { observerMap } from "@microsoft/fast-element";
143+
import { observerMap } from "@microsoft/fast-element/observer-map.js";
144144
```
145145

146146
For finer control, pass a configuration object with a `properties` key that maps root property names to a recursive path tree:
@@ -195,9 +195,8 @@ are observed.
195195
Manual schema example:
196196

197197
```typescript
198-
import { FASTElement } from "@microsoft/fast-element";
199-
import { Schema } from "@microsoft/fast-element";
200-
import { observerMap } from "@microsoft/fast-element";
198+
import { FASTElement, Schema } from "@microsoft/fast-element";
199+
import { observerMap } from "@microsoft/fast-element/observer-map.js";
201200

202201
class MyElement extends FASTElement {}
203202

@@ -227,7 +226,7 @@ on the FAST element definition and import `attributeMap()` from
227226
`@microsoft/fast-element`.
228227

229228
```typescript
230-
import { attributeMap } from "@microsoft/fast-element";
229+
import { attributeMap } from "@microsoft/fast-element/attribute-map.js";
231230
```
232231

233232
By default, the binding key is treated as a camelCase property name and the HTML

packages/fast-element/DECLARATIVE_MIGRATION.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ implementation is internal and is defined automatically by `declarativeTemplate(
174174
| `AttributeMap` / `ObserverMap` class exports from the old declarative public surface | `attributeMap()` / `observerMap()` extension helpers and their config types |
175175

176176
Hydration is also no longer installed by `@microsoft/fast-element`.
177-
Call `enableHydration()` from `@microsoft/fast-element` before FAST
177+
Call `enableHydration()` from `@microsoft/fast-element/hydration.js` before FAST
178178
elements connect when prerendered Declarative Shadow DOM should be reused.
179179

180180
## Schema-driven maps and optional definition schema
@@ -184,8 +184,8 @@ factored away from declarative templating. Import them from
184184
`@microsoft/fast-element` for declarative or non-declarative use:
185185

186186
```ts
187-
import { attributeMap } from "@microsoft/fast-element";
188-
import { observerMap } from "@microsoft/fast-element";
187+
import { attributeMap } from "@microsoft/fast-element/attribute-map.js";
188+
import { observerMap } from "@microsoft/fast-element/observer-map.js";
189189
```
190190

191191
`FASTElementDefinition.schema` is optional. `declarativeTemplate()` assigns it
@@ -194,9 +194,8 @@ a schema in the element definition, and `observerMap()` can also take a schema
194194
directly in configuration:
195195

196196
```ts
197-
import { FASTElement } from "@microsoft/fast-element";
198-
import { Schema } from "@microsoft/fast-element";
199-
import { observerMap } from "@microsoft/fast-element";
197+
import { FASTElement, Schema } from "@microsoft/fast-element";
198+
import { observerMap } from "@microsoft/fast-element/observer-map.js";
200199

201200
class MyElement extends FASTElement {}
202201

packages/fast-element/DECLARATIVE_RENDERING.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Add a Dependency Injection service in your bundle to access properties in your s
2222

2323
Simple example (`initial-state.ts`):
2424
```typescript
25-
import { DI } from "@microsoft/fast-element";
25+
import { DI } from "@microsoft/fast-element/di.js";
2626

2727
interface InitialState {
2828
text: string;
@@ -60,15 +60,13 @@ Include the DI service to your component.
6060

6161
Example:
6262
```typescript
63-
import { FASTElement } from "@microsoft/fast-element";
64-
import { attr } from "@microsoft/fast-element";
65-
import { Observable } from "@microsoft/fast-element";
63+
import { attr, FASTElement, Observable } from "@microsoft/fast-element";
6664
import {
6765
initialStateFactory,
6866
InitialStateService,
6967
type IInitialStateService,
7068
} from "./initial-state.js";
71-
import { inject } from '@microsoft/fast-element';
69+
import { inject } from "@microsoft/fast-element/di.js";
7270

7371
export class MyComponent extends FASTElement {
7472
@inject(initialStateFactory) initialStateService!: InitialStateService;

packages/fast-element/DECLARATIVE_RENDERING_LIFECYCLE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Key characteristics of this phase:
6262

6363
### Phase 2: Declarative Template Bridge
6464

65-
`declarativeTemplate()` from `@microsoft/fast-element`
65+
`declarativeTemplate()` from `@microsoft/fast-element/declarative.js`
6666
automatically ensures that `f-template` is defined in the same registry as the
6767
FAST element being composed.
6868

@@ -203,8 +203,8 @@ Hydration must be explicitly opted into by calling `enableHydration()`. Per-elem
203203
callbacks are passed directly to `declarativeTemplate()`:
204204

205205
```typescript
206-
import { enableHydration } from "@microsoft/fast-element";
207-
import { declarativeTemplate } from "@microsoft/fast-element";
206+
import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
207+
import { enableHydration } from "@microsoft/fast-element/hydration.js";
208208

209209
// Global hydration events
210210
enableHydration({
@@ -246,8 +246,8 @@ MyComponent.define({
246246

247247
**Performance Monitoring:**
248248
```typescript
249-
import { enableHydration } from "@microsoft/fast-element";
250-
import { declarativeTemplate } from "@microsoft/fast-element";
249+
import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
250+
import { enableHydration } from "@microsoft/fast-element/hydration.js";
251251

252252
enableHydration({
253253
hydrationComplete() {

packages/fast-element/DECLARATIVE_SCHEMA_OBSERVER_MAP.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ The Schema and Observer Map classes integrate seamlessly with the f-template sys
161161
### Configuration
162162

163163
Observer Map functionality is enabled through the `observerMap()` definition
164-
extension exported from `@microsoft/fast-element`:
164+
extension exported from `@microsoft/fast-element/observer-map.js`:
165165

166166
```typescript
167-
import { declarativeTemplate } from "@microsoft/fast-element";
168-
import { observerMap } from "@microsoft/fast-element";
167+
import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
168+
import { observerMap } from "@microsoft/fast-element/observer-map.js";
169169

170170
MyElement.define(
171171
{
@@ -184,9 +184,8 @@ For non-declarative/manual schema use, pass the schema in the observer map
184184
configuration:
185185

186186
```typescript
187-
import { FASTElement } from "@microsoft/fast-element";
188-
import { Schema } from "@microsoft/fast-element";
189-
import { observerMap } from "@microsoft/fast-element";
187+
import { FASTElement, Schema } from "@microsoft/fast-element";
188+
import { observerMap } from "@microsoft/fast-element/observer-map.js";
190189

191190
class MyElement extends FASTElement {}
192191

@@ -475,8 +474,7 @@ To verify that observer mapping ran, inspect the generated schema and the
475474
observable accessors on the element prototype:
476475

477476
```typescript
478-
import { schemaRegistry } from "@microsoft/fast-element";
479-
import { Observable } from "@microsoft/fast-element";
477+
import { Observable, schemaRegistry } from "@microsoft/fast-element";
480478
481479
const schemas = schemaRegistry.get("my-element");
482480
const accessors = Observable.getAccessors(MyElement.prototype).map(a => a.name);

0 commit comments

Comments
 (0)