@homepages/concrete 1.0.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.
- package/CHANGELOG.md +59 -0
- package/README.md +174 -0
- package/codemods/manifest.json +9 -0
- package/dist/artifact/playground/client/assets/index-BSA1yutg.css +1 -0
- package/dist/artifact/playground/client/assets/index-JloQyj8h.js +1101 -0
- package/dist/artifact/playground/client/index.html +13 -0
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -0
- package/dist/artifact/playground/host.mjs +127 -0
- package/dist/asset-modules.d.ts +99 -0
- package/dist/base.css +220 -0
- package/dist/browser/site-config.d.ts +18 -0
- package/dist/browser/site-config.js +56 -0
- package/dist/browser/submit-lead.d.ts +98 -0
- package/dist/browser/submit-lead.js +188 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +4 -0
- package/dist/cli/build/artifact.js +225 -0
- package/dist/cli/build/captures.js +67 -0
- package/dist/cli/build/esbuild.js +127 -0
- package/dist/cli/build/fixtures.js +96 -0
- package/dist/cli/build/icons.js +76 -0
- package/dist/cli/build/index.js +38 -0
- package/dist/cli/build/playground.js +31 -0
- package/dist/cli/build/sections.js +236 -0
- package/dist/cli/build/source.js +62 -0
- package/dist/cli/build/static.js +156 -0
- package/dist/cli/capture/bundle.js +37 -0
- package/dist/cli/capture/capture-browser.js +51 -0
- package/dist/cli/capture/capture.js +121 -0
- package/dist/cli/check/analyze.js +95 -0
- package/dist/cli/check/index.js +19 -0
- package/dist/cli/check/load-workspace.js +119 -0
- package/dist/cli/check/messages.js +16 -0
- package/dist/cli/check/render/class-conflicts.js +39 -0
- package/dist/cli/check/render/html.js +86 -0
- package/dist/cli/check/render/inputs.js +53 -0
- package/dist/cli/check/render/invariants.js +58 -0
- package/dist/cli/check/render/island-frames.js +72 -0
- package/dist/cli/check/render/marker-coverage.js +102 -0
- package/dist/cli/check/render/nav.js +64 -0
- package/dist/cli/check/report.js +73 -0
- package/dist/cli/check/stages/bundles.js +129 -0
- package/dist/cli/check/stages/composition.js +67 -0
- package/dist/cli/check/stages/contracts.js +22 -0
- package/dist/cli/check/stages/dependencies.js +261 -0
- package/dist/cli/check/stages/fixtures.js +74 -0
- package/dist/cli/check/stages/lint.js +41 -0
- package/dist/cli/check/stages/logic.js +63 -0
- package/dist/cli/check/stages/render.js +144 -0
- package/dist/cli/check/stages/sections.js +83 -0
- package/dist/cli/check/stages/stylesheet.js +31 -0
- package/dist/cli/check/stages/typecheck.js +68 -0
- package/dist/cli/check/stages/workspace.js +26 -0
- package/dist/cli/commands.js +342 -0
- package/dist/cli/currency/cache.js +89 -0
- package/dist/cli/currency/decide.js +65 -0
- package/dist/cli/currency/opt-out.js +16 -0
- package/dist/cli/currency/preamble.js +183 -0
- package/dist/cli/currency/prompt.js +28 -0
- package/dist/cli/currency/refresh.js +44 -0
- package/dist/cli/currency/resolve-latest.js +185 -0
- package/dist/cli/currency/version-order.js +38 -0
- package/dist/cli/dev/crop.js +22 -0
- package/dist/cli/dev/hmr.js +26 -0
- package/dist/cli/dev/http.js +129 -0
- package/dist/cli/dev/index.js +70 -0
- package/dist/cli/dev/islands.js +390 -0
- package/dist/cli/dev/load-template.js +46 -0
- package/dist/cli/dev/request-error.js +22 -0
- package/dist/cli/dev/server.js +307 -0
- package/dist/cli/dev/tsconfig-paths.js +95 -0
- package/dist/cli/dev/vite.js +85 -0
- package/dist/cli/dev/workspace-reader.js +274 -0
- package/dist/cli/io.d.ts +14 -0
- package/dist/cli/media/cache.js +125 -0
- package/dist/cli/media/derive.js +252 -0
- package/dist/cli/media/deriver-plugin.js +71 -0
- package/dist/cli/property/index.js +180 -0
- package/dist/cli/property/library.js +137 -0
- package/dist/cli/publish/client.js +119 -0
- package/dist/cli/publish/freshness.js +66 -0
- package/dist/cli/publish/git.js +43 -0
- package/dist/cli/publish/index.js +207 -0
- package/dist/cli/publish/pack.js +78 -0
- package/dist/cli/publish/report.js +98 -0
- package/dist/cli/publish/target.js +87 -0
- package/dist/cli/publish/wire.js +29 -0
- package/dist/cli/tar.js +87 -0
- package/dist/cli/upgrade/codemod.js +56 -0
- package/dist/cli/upgrade/index.js +263 -0
- package/dist/cli/upgrade/manifest.js +72 -0
- package/dist/cli/upgrade/plan.js +68 -0
- package/dist/cli/upgrade/stage.js +71 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.js +15 -0
- package/dist/cli/workspace.js +108 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +94 -0
- package/dist/css/compile.js +77 -0
- package/dist/css/graph.js +109 -0
- package/dist/css/inline.js +132 -0
- package/dist/css/rules.js +65 -0
- package/dist/design-system/format-variants.js +127 -0
- package/dist/eslint/authoring.js +46 -0
- package/dist/eslint/correctness.js +42 -0
- package/dist/eslint/rules/editor-declaration.js +103 -0
- package/dist/eslint/rules/editor-reason.js +135 -0
- package/dist/eslint/rules/island-imports.js +20 -0
- package/dist/eslint/rules/jsx-visitor.js +20 -0
- package/dist/eslint/rules/no-client-runtime.js +88 -0
- package/dist/eslint/rules/no-editor-globals.js +60 -0
- package/dist/eslint/rules/no-hard-coded-color.js +183 -0
- package/dist/eslint/rules/no-inline-style.js +24 -0
- package/dist/eslint/rules/no-marker-literal.js +37 -0
- package/dist/eslint/rules/no-nondeterminism.js +44 -0
- package/dist/eslint/rules/no-px-breakpoint.js +44 -0
- package/dist/eslint/rules/no-raw-values.js +45 -0
- package/dist/eslint/rules/serializable-props.js +95 -0
- package/dist/eslint.d.ts +6 -0
- package/dist/eslint.js +26 -0
- package/dist/fixtures/brand.d.ts +4 -0
- package/dist/fixtures/brand.js +9 -0
- package/dist/fixtures/bundle-rule.js +67 -0
- package/dist/fixtures/canonical.d.ts +149 -0
- package/dist/fixtures/image-dimensions.js +59 -0
- package/dist/fixtures/load.js +154 -0
- package/dist/fixtures/media-plugin.js +141 -0
- package/dist/fixtures/media.js +165 -0
- package/dist/fixtures/property.js +210 -0
- package/dist/fixtures/resolve.js +202 -0
- package/dist/fixtures/rows.js +108 -0
- package/dist/fixtures/synthesize-empties.js +42 -0
- package/dist/fixtures.d.ts +213 -0
- package/dist/fixtures.js +37 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +37 -0
- package/dist/islands/client-module.js +97 -0
- package/dist/islands/marker.d.ts +43 -0
- package/dist/islands/marker.js +44 -0
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +687 -0
- package/dist/packages/external/concrete/package.js +5 -0
- package/dist/packages/internal/fact-interpolation/dist/index.js +22 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +111 -0
- package/dist/packages/internal/fill-bake/dist/display.js +9 -0
- package/dist/packages/internal/fill-bake/dist/index.js +6 -0
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +170 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +32 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +131 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +73 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +404 -0
- package/dist/packages/internal/format-geometry/dist/format.d.ts +41 -0
- package/dist/packages/internal/format-geometry/dist/geometry.js +58 -0
- package/dist/packages/internal/format-geometry/dist/index.js +4 -0
- package/dist/packages/internal/image-descriptor/dist/index.d.ts +35 -0
- package/dist/packages/internal/image-ladder/dist/crop.js +82 -0
- package/dist/packages/internal/image-ladder/dist/encode.js +23 -0
- package/dist/packages/internal/image-ladder/dist/index.js +4 -0
- package/dist/packages/internal/image-ladder/dist/policy.js +102 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.d.ts +13 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +45 -0
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +176 -0
- package/dist/packages/internal/island-runtime/dist/contract.js +94 -0
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +15 -0
- package/dist/packages/internal/island-runtime/dist/index.d.ts +103 -0
- package/dist/packages/internal/island-runtime/dist/index.js +163 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +19 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +39 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.d.ts +22 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.js +54 -0
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +105 -0
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +25 -0
- package/dist/packages/internal/property-facts/dist/index.js +3 -0
- package/dist/packages/internal/property-facts/dist/property-facts-CSdkSuD7.js +181 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +59 -0
- package/dist/packages/internal/section-contracts/dist/catalog.js +102 -0
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/display-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +17 -0
- package/dist/packages/internal/section-contracts/dist/group-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/index.js +26 -0
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +53 -0
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +70 -0
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +12 -0
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +22 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +18 -0
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/row-contract.js +37 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +38 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +181 -0
- package/dist/packages/internal/section-contracts/dist/select-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/source-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +15 -0
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/url-contract.js +20 -0
- package/dist/packages/internal/source-resolution/dist/index.js +222 -0
- package/dist/packages/internal/template-artifact/dist/hash.js +50 -0
- package/dist/packages/internal/template-artifact/dist/index.js +7 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +165 -0
- package/dist/packages/internal/template-artifact/dist/manifest.js +73 -0
- package/dist/packages/internal/template-artifact/dist/sha256.js +138 -0
- package/dist/packages/internal/template-artifact/dist/verify.js +275 -0
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +38 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.d.ts +10 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.js +17 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +33 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +81 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.js +136 -0
- package/dist/packages/internal/template-contracts/dist/layout.js +17 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +40 -0
- package/dist/packages/internal/template-contracts/dist/markers.js +41 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +63 -0
- package/dist/packages/internal/template-contracts/dist/select-key.js +13 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1112 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1109 -0
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +11 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +45 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +63 -0
- package/dist/playground/host/page-state.js +12 -0
- package/dist/playground/host/paths.js +9 -0
- package/dist/playground/layout.js +24 -0
- package/dist/playground/wire.js +36 -0
- package/dist/playground-island-runtime.d.ts +3 -0
- package/dist/playground-island-runtime.js +4 -0
- package/dist/primitives/FrameShell.d.ts +29 -0
- package/dist/primitives/FrameShell.js +34 -0
- package/dist/primitives/Image.d.ts +119 -0
- package/dist/primitives/Image.js +173 -0
- package/dist/primitives/Section.d.ts +22 -0
- package/dist/primitives/Section.js +26 -0
- package/dist/primitives/Tour.d.ts +43 -0
- package/dist/primitives/Tour.js +72 -0
- package/dist/primitives/Video.d.ts +57 -0
- package/dist/primitives/Video.js +116 -0
- package/dist/primitives/embed-playback.js +50 -0
- package/dist/primitives/index.d.ts +11 -0
- package/dist/primitives/marker-attrs.js +44 -0
- package/dist/primitives/object-fit.js +11 -0
- package/dist/primitives/picture-sources.d.ts +24 -0
- package/dist/primitives/picture-sources.js +52 -0
- package/dist/primitives/probe-context.js +24 -0
- package/dist/primitives/slot-bindings.d.ts +96 -0
- package/dist/primitives/slot-bindings.js +226 -0
- package/dist/primitives/slot-document.d.ts +35 -0
- package/dist/primitives/slot-document.js +37 -0
- package/dist/primitives/slot-group.d.ts +40 -0
- package/dist/primitives/slot-group.js +45 -0
- package/dist/primitives/slot-list.d.ts +21 -0
- package/dist/primitives/slot-list.js +23 -0
- package/dist/primitives/slot-media.d.ts +71 -0
- package/dist/primitives/slot-media.js +98 -0
- package/dist/primitives/slot-scalar.d.ts +53 -0
- package/dist/primitives/slot-scalar.js +98 -0
- package/dist/primitives/slot.d.ts +26 -0
- package/dist/primitives/slot.js +28 -0
- package/dist/rules/registry.js +479 -0
- package/dist/schema/compute.d.ts +22 -0
- package/dist/schema/compute.js +30 -0
- package/dist/schema/define-schema.d.ts +27 -0
- package/dist/schema/define-schema.js +73 -0
- package/dist/schema/extract-fill-spec.js +246 -0
- package/dist/schema/extract-used-facts.js +176 -0
- package/dist/schema/fact.d.ts +65 -0
- package/dist/schema/fact.js +33 -0
- package/dist/schema/fill-builders.d.ts +387 -0
- package/dist/schema/fill-builders.js +263 -0
- package/dist/schema/fill-declaration.d.ts +76 -0
- package/dist/schema/fill-declaration.js +43 -0
- package/dist/schema/fill-spec.d.ts +18 -0
- package/dist/schema/fill-spec.js +170 -0
- package/dist/schema/format-presets.d.ts +27 -0
- package/dist/schema/format-presets.js +76 -0
- package/dist/schema/format.d.ts +22 -0
- package/dist/schema/format.js +40 -0
- package/dist/schema/formats.d.ts +6 -0
- package/dist/schema/formats.js +7 -0
- package/dist/schema/layout.d.ts +32 -0
- package/dist/schema/layout.js +30 -0
- package/dist/schema/manifest.js +300 -0
- package/dist/schema/property-facts.d.ts +83 -0
- package/dist/schema/runtime-values.d.ts +88 -0
- package/dist/schema/section-nav.d.ts +38 -0
- package/dist/schema/section-nav.js +29 -0
- package/dist/schema/section-props.d.ts +98 -0
- package/dist/schema/section-schema.d.ts +53 -0
- package/dist/schema/section-schema.js +54 -0
- package/dist/schema/slot-builders.d.ts +497 -0
- package/dist/schema/slot-builders.js +331 -0
- package/dist/schema/slot-types.d.ts +110 -0
- package/dist/schema/slot-types.js +187 -0
- package/dist/section/declare.d.ts +44 -0
- package/dist/section/declare.js +27 -0
- package/dist/section/discovery.js +76 -0
- package/dist/section/groups.js +74 -0
- package/dist/section/materialize.js +28 -0
- package/dist/section/placements.js +28 -0
- package/dist/section/section.d.ts +69 -0
- package/dist/section/section.js +101 -0
- package/dist/site-analytics.d.ts +1 -0
- package/dist/site-analytics.js +15 -0
- package/dist/site-runtime/analytics.js +97 -0
- package/dist/site-runtime/site-integrations.js +97 -0
- package/dist/styles.css +60 -0
- package/dist/template/define-template.d.ts +139 -0
- package/dist/template/define-template.js +98 -0
- package/dist/template/logic-build.js +191 -0
- package/dist/template/logic-shim.d.ts +43 -0
- package/dist/template/logic-shim.js +52 -0
- package/dist/template/logic-transform.js +92 -0
- package/dist/template/materialize.js +107 -0
- package/dist/template/reconcile.d.ts +67 -0
- package/dist/template/reconcile.js +25 -0
- package/dist/template/running-copy.js +58 -0
- package/guide/reference/cli/INDEX.md +79 -0
- package/guide/reference/cli/build.md +48 -0
- package/guide/reference/cli/check.md +49 -0
- package/guide/reference/cli/dev.md +46 -0
- package/guide/reference/cli/property-add.md +53 -0
- package/guide/reference/cli/property-list.md +46 -0
- package/guide/reference/cli/publish.md +54 -0
- package/guide/reference/cli/upgrade.md +48 -0
- package/guide/reference/rules/INDEX.md +190 -0
- package/package.json +137 -0
- package/tsconfig.base.json +16 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { version } from "./packages/external/concrete/package.js";
|
|
2
|
+
import { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandPropsError, deserializeIslandProps, islandId, serializeIslandProps } from "./packages/internal/island-runtime/dist/contract.js";
|
|
3
|
+
import { useEditor } from "./packages/internal/island-runtime/dist/use-editor.js";
|
|
4
|
+
import { useCaptureReady } from "./packages/internal/island-runtime/dist/use-capture-ready.js";
|
|
5
|
+
import { IslandMarker } from "./islands/marker.js";
|
|
6
|
+
import { bindItems } from "./primitives/slot-bindings.js";
|
|
7
|
+
import { compute } from "./schema/compute.js";
|
|
8
|
+
import { section } from "./section/section.js";
|
|
9
|
+
import { defineTemplate } from "./template/define-template.js";
|
|
10
|
+
import { rule, set } from "./template/reconcile.js";
|
|
11
|
+
import { FrameShell } from "./primitives/FrameShell.js";
|
|
12
|
+
import { ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE } from "./packages/internal/template-contracts/dist/markers.js";
|
|
13
|
+
import { Image } from "./primitives/Image.js";
|
|
14
|
+
import { Section } from "./primitives/Section.js";
|
|
15
|
+
import { SlotGroup } from "./primitives/slot-group.js";
|
|
16
|
+
import { Tour } from "./primitives/Tour.js";
|
|
17
|
+
import { Video } from "./primitives/Video.js";
|
|
18
|
+
import { Slot } from "./primitives/slot.js";
|
|
19
|
+
import { document, image, list, number, poi, select, text, tour, url, video } from "./schema/slot-builders.js";
|
|
20
|
+
import { fact } from "./schema/fact.js";
|
|
21
|
+
import { chooseFrom, contactAssign, documentAssign, imageAssign, listFill, nameRows, textBlock, tourAssign, videoAssign } from "./schema/fill-builders.js";
|
|
22
|
+
import { presets } from "./schema/format-presets.js";
|
|
23
|
+
import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, instagramPortrait, instagramSquare, instagramStory, letterLandscape, letterPortrait, linkedinPost, postcard6x4, postcard7x5, website, xPost } from "./schema/formats.js";
|
|
24
|
+
|
|
25
|
+
//#region src/index.ts
|
|
26
|
+
/**
|
|
27
|
+
* The published version of this package.
|
|
28
|
+
*
|
|
29
|
+
* Read from package.json and inlined at build time, so it cannot drift: changesets
|
|
30
|
+
* owns package.json's version, and a hardcoded constant would have to be hand-edited
|
|
31
|
+
* on every release. src/index.test.ts asserts it against package.json to prove the
|
|
32
|
+
* inlining actually happened.
|
|
33
|
+
*/
|
|
34
|
+
const CONCRETE_VERSION = version;
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE, CONCRETE_VERSION, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, FrameShell, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, Image, IslandMarker, IslandPropsError, Section, Slot, SlotGroup, Tour, Video, a4Landscape, a4Portrait, bindItems, chooseFrom, compute, contactAssign, deck16x9, defineTemplate, deserializeIslandProps, document, documentAssign, facebookPost, fact, halfLetterFlyer, image, imageAssign, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, listFill, nameRows, number, poi, postcard6x4, postcard7x5, presets, rule, section, select, serializeIslandProps, set, text, textBlock, tour, tourAssign, url, useCaptureReady, useEditor, video, videoAssign, website, xPost };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createPathsResolver } from "../cli/dev/tsconfig-paths.js";
|
|
2
|
+
import { readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
|
|
6
|
+
//#region src/islands/client-module.ts
|
|
7
|
+
/**
|
|
8
|
+
* Whether source text opens with a `"use client"` directive — among the leading
|
|
9
|
+
* string-literal statements (the directive prologue). Anything else ends the prologue.
|
|
10
|
+
*/
|
|
11
|
+
function hasClientDirective(text) {
|
|
12
|
+
let i = 0;
|
|
13
|
+
while (i < text.length) {
|
|
14
|
+
const rest = text.slice(i);
|
|
15
|
+
const ws = /^\s+/.exec(rest);
|
|
16
|
+
if (ws) {
|
|
17
|
+
i += ws[0].length;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const line = /^\/\/[^\n]*/.exec(rest);
|
|
21
|
+
if (line) {
|
|
22
|
+
i += line[0].length;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const block = /^\/\*[\s\S]*?\*\//.exec(rest);
|
|
26
|
+
if (block) {
|
|
27
|
+
i += block[0].length;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const directive = /^(["'])([^"']*)\1\s*;?/.exec(rest);
|
|
31
|
+
if (!directive) return false;
|
|
32
|
+
if (directive[2] === "use client") return true;
|
|
33
|
+
i += directive[0].length;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const clientFiles = /* @__PURE__ */ new Map();
|
|
38
|
+
const pathsResolvers = /* @__PURE__ */ new Map();
|
|
39
|
+
function mtimeOf(path) {
|
|
40
|
+
try {
|
|
41
|
+
const stat = statSync(path);
|
|
42
|
+
return stat.isFile() ? stat.mtimeMs : void 0;
|
|
43
|
+
} catch {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Whether the file at `path` opens with a `"use client"` directive. An unreadable or missing file is not a client module. */
|
|
48
|
+
function isClientFile(path) {
|
|
49
|
+
const absolute = resolve(path);
|
|
50
|
+
const mtime = mtimeOf(absolute);
|
|
51
|
+
if (mtime === void 0) return false;
|
|
52
|
+
const key = `${absolute}:${mtime}`;
|
|
53
|
+
const hit = clientFiles.get(key);
|
|
54
|
+
if (hit !== void 0) return hit;
|
|
55
|
+
let answer;
|
|
56
|
+
try {
|
|
57
|
+
answer = hasClientDirective(readFileSync(absolute, "utf8"));
|
|
58
|
+
} catch {
|
|
59
|
+
answer = false;
|
|
60
|
+
}
|
|
61
|
+
clientFiles.set(key, answer);
|
|
62
|
+
return answer;
|
|
63
|
+
}
|
|
64
|
+
const SOURCE_EXTS = [
|
|
65
|
+
".tsx",
|
|
66
|
+
".ts",
|
|
67
|
+
".jsx",
|
|
68
|
+
".js"
|
|
69
|
+
];
|
|
70
|
+
function firstFile(base) {
|
|
71
|
+
const candidates = [];
|
|
72
|
+
const emitted = /\.(js|jsx)$/.exec(base);
|
|
73
|
+
if (emitted) candidates.push(...SOURCE_EXTS.map((ext) => base.slice(0, -emitted[0].length) + ext));
|
|
74
|
+
candidates.push(base, ...SOURCE_EXTS.map((ext) => base + ext), ...SOURCE_EXTS.map((ext) => `${base}/index${ext}`));
|
|
75
|
+
return candidates.find((candidate) => mtimeOf(candidate) !== void 0) ?? null;
|
|
76
|
+
}
|
|
77
|
+
/** The tsconfig `paths` resolver of the nearest tsconfig.json above `fromFile`, or `null`. */
|
|
78
|
+
function pathsResolverFor(fromFile) {
|
|
79
|
+
const config = ts.findConfigFile(dirname(fromFile), (file) => ts.sys.fileExists(file));
|
|
80
|
+
if (config === void 0) return null;
|
|
81
|
+
const key = `${config}:${mtimeOf(config)}`;
|
|
82
|
+
if (!pathsResolvers.has(key)) pathsResolvers.set(key, createPathsResolver(ts, dirname(config)));
|
|
83
|
+
return pathsResolvers.get(key) ?? null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The workspace file an import specifier, written in `fromFile`, names: a relative
|
|
87
|
+
* specifier, or one mapped by the workspace tsconfig's `paths` (the scaffold's `@/*`).
|
|
88
|
+
* `null` for a package specifier, or when no candidate is a real file.
|
|
89
|
+
*/
|
|
90
|
+
function resolveImportedFile(specifier, fromFile) {
|
|
91
|
+
if (specifier.startsWith(".")) return firstFile(resolve(dirname(fromFile), specifier));
|
|
92
|
+
const mapped = pathsResolverFor(resolve(fromFile))?.(specifier);
|
|
93
|
+
return mapped === void 0 ? null : firstFile(mapped);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
export { hasClientDirective, isClientFile, resolveImportedFile };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IslandProps } from "../packages/internal/island-runtime/dist/contract.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/islands/marker.d.ts
|
|
4
|
+
/** Props for {@link IslandMarker}. */
|
|
5
|
+
interface IslandMarkerProps {
|
|
6
|
+
/** `<section-key>:<ComponentName>` — the key the browser loader resolves the module by. */
|
|
7
|
+
islandKey: string;
|
|
8
|
+
/** Unique in the document, stable across re-renders of this island. Compose with `islandId()`. */
|
|
9
|
+
islandId: string;
|
|
10
|
+
/** Strictly JSON-serializable. A bad prop throws IslandPropsError here, at render time. */
|
|
11
|
+
props: IslandProps;
|
|
12
|
+
/**
|
|
13
|
+
* The client component, server-rendered. Omitted for an island with no server-rendered
|
|
14
|
+
* first frame — the marker then declares itself frameless (see {@link IslandMarker}).
|
|
15
|
+
*/
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Wrap a client component's server-rendered output in the island DOM shape: a
|
|
20
|
+
* layout-invisible custom element carrying the island's key and id, plus a sibling
|
|
21
|
+
* `<script type="application/json">` payload the browser runtime reads the props
|
|
22
|
+
* back out of. This is the one place that shape is written — every renderer and
|
|
23
|
+
* every "use client" wrapping goes through it.
|
|
24
|
+
*
|
|
25
|
+
* Both nodes set `suppressHydrationWarning`, scoped to themselves (it does not
|
|
26
|
+
* descend, so a real mismatch inside the island still reports). A NESTED island's
|
|
27
|
+
* marker is rendered on the client as well as the server — that is what lets its
|
|
28
|
+
* parent island's client render match the markup SSR produced — and `islandId` comes
|
|
29
|
+
* from `useId`, which counts from the root of the tree being rendered. The server
|
|
30
|
+
* renders a whole section under an `identifierPrefix`; the client hydrates a subtree
|
|
31
|
+
* rooted at one marker, with no prefix. The two ids therefore diverge by construction
|
|
32
|
+
* and cannot be reconciled by passing a prefix. That divergence is inert: React leaves
|
|
33
|
+
* the server's ids in the DOM, the marker and its payload come from the same `islandId`
|
|
34
|
+
* in one render so they stay paired under either outcome, and a nested marker's id is
|
|
35
|
+
* never read — `hydrateIslands` skips nested markers, leaving them to their parent.
|
|
36
|
+
*
|
|
37
|
+
* No children means no server-rendered output, and the marker says so on itself with
|
|
38
|
+
* `data-tr-island-frameless` — the browser loader mounts such an island fresh rather
|
|
39
|
+
* than hydrating it against markup that was never emitted.
|
|
40
|
+
*/
|
|
41
|
+
declare function IslandMarker({ islandKey, islandId, props, children }: IslandMarkerProps): ReactNode;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { IslandMarker, IslandMarkerProps };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ISLAND_ELEMENT, serializeIslandProps } from "../packages/internal/island-runtime/dist/contract.js";
|
|
2
|
+
import { Fragment, createElement } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/islands/marker.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Wrap a client component's server-rendered output in the island DOM shape: a
|
|
7
|
+
* layout-invisible custom element carrying the island's key and id, plus a sibling
|
|
8
|
+
* `<script type="application/json">` payload the browser runtime reads the props
|
|
9
|
+
* back out of. This is the one place that shape is written — every renderer and
|
|
10
|
+
* every "use client" wrapping goes through it.
|
|
11
|
+
*
|
|
12
|
+
* Both nodes set `suppressHydrationWarning`, scoped to themselves (it does not
|
|
13
|
+
* descend, so a real mismatch inside the island still reports). A NESTED island's
|
|
14
|
+
* marker is rendered on the client as well as the server — that is what lets its
|
|
15
|
+
* parent island's client render match the markup SSR produced — and `islandId` comes
|
|
16
|
+
* from `useId`, which counts from the root of the tree being rendered. The server
|
|
17
|
+
* renders a whole section under an `identifierPrefix`; the client hydrates a subtree
|
|
18
|
+
* rooted at one marker, with no prefix. The two ids therefore diverge by construction
|
|
19
|
+
* and cannot be reconciled by passing a prefix. That divergence is inert: React leaves
|
|
20
|
+
* the server's ids in the DOM, the marker and its payload come from the same `islandId`
|
|
21
|
+
* in one render so they stay paired under either outcome, and a nested marker's id is
|
|
22
|
+
* never read — `hydrateIslands` skips nested markers, leaving them to their parent.
|
|
23
|
+
*
|
|
24
|
+
* No children means no server-rendered output, and the marker says so on itself with
|
|
25
|
+
* `data-tr-island-frameless` — the browser loader mounts such an island fresh rather
|
|
26
|
+
* than hydrating it against markup that was never emitted.
|
|
27
|
+
*/
|
|
28
|
+
function IslandMarker({ islandKey, islandId, props, children }) {
|
|
29
|
+
return createElement(Fragment, null, createElement(ISLAND_ELEMENT, {
|
|
30
|
+
style: { display: "contents" },
|
|
31
|
+
[ATTR_ISLAND_KEY]: islandKey,
|
|
32
|
+
[ATTR_ISLAND_ID]: islandId,
|
|
33
|
+
[ATTR_ISLAND_FRAMELESS]: children == null ? "" : void 0,
|
|
34
|
+
suppressHydrationWarning: true
|
|
35
|
+
}, children), createElement("script", {
|
|
36
|
+
type: "application/json",
|
|
37
|
+
[ATTR_ISLAND_PROPS]: islandId,
|
|
38
|
+
suppressHydrationWarning: true,
|
|
39
|
+
dangerouslySetInnerHTML: { __html: serializeIslandProps(props) }
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { IslandMarker };
|