@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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsxVisitor } from "./jsx-visitor.js";
|
|
2
|
+
|
|
3
|
+
//#region src/eslint/rules/no-marker-literal.ts
|
|
4
|
+
const MARKER_PREFIX = "data-slot-";
|
|
5
|
+
const noMarkerLiteral = {
|
|
6
|
+
meta: {
|
|
7
|
+
type: "problem",
|
|
8
|
+
docs: { description: "Ban hand-written data-slot-* markers" },
|
|
9
|
+
schema: [],
|
|
10
|
+
messages: { markerLiteral: "data-slot-* markers are the editor's wire format, emitted by the slot primitives from your section's slots; a hand-written one can drift from them and silently break selection and patching. Fix: render the slot through its primitive (`Slot.Text`, `Slot.Image`, `SlotGroup`, …) instead of writing the attribute yourself." }
|
|
11
|
+
},
|
|
12
|
+
create(context) {
|
|
13
|
+
return {
|
|
14
|
+
JSXAttribute: jsxVisitor((node) => {
|
|
15
|
+
if (node.name.type === "JSXIdentifier" && node.name.name?.startsWith(MARKER_PREFIX) === true) context.report({
|
|
16
|
+
node,
|
|
17
|
+
messageId: "markerLiteral"
|
|
18
|
+
});
|
|
19
|
+
}),
|
|
20
|
+
Literal(node) {
|
|
21
|
+
if (typeof node.value === "string" && node.value.includes(MARKER_PREFIX)) context.report({
|
|
22
|
+
node,
|
|
23
|
+
messageId: "markerLiteral"
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
TemplateLiteral(node) {
|
|
27
|
+
if (node.quasis.some((quasi) => quasi.value.cooked?.includes(MARKER_PREFIX) === true)) context.report({
|
|
28
|
+
node,
|
|
29
|
+
messageId: "markerLiteral"
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { noMarkerLiteral };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { hasClientDirective } from "../../islands/client-module.js";
|
|
2
|
+
|
|
3
|
+
//#region src/eslint/rules/no-nondeterminism.ts
|
|
4
|
+
const BANNED_MEMBERS = {
|
|
5
|
+
Date: /* @__PURE__ */ new Set(["now"]),
|
|
6
|
+
Math: /* @__PURE__ */ new Set(["random"]),
|
|
7
|
+
crypto: /* @__PURE__ */ new Set(["randomUUID", "getRandomValues"]),
|
|
8
|
+
performance: /* @__PURE__ */ new Set(["now"])
|
|
9
|
+
};
|
|
10
|
+
const noNondeterminism = {
|
|
11
|
+
meta: {
|
|
12
|
+
type: "problem",
|
|
13
|
+
docs: { description: "Ban clock and randomness reads in server-rendered code" },
|
|
14
|
+
schema: [],
|
|
15
|
+
messages: { nondeterministic: "`{{what}}` is nondeterministic and is banned in server-rendered code: the publisher and the editor must render byte-identical HTML. Fix: compute this at fill time and pass it in as a slot value, or move the code into a `\"use client\"` island, where it runs in the browser." }
|
|
16
|
+
},
|
|
17
|
+
create(context) {
|
|
18
|
+
if (hasClientDirective(context.sourceCode.getText())) return {};
|
|
19
|
+
const sourceCode = context.sourceCode;
|
|
20
|
+
return {
|
|
21
|
+
MemberExpression(node) {
|
|
22
|
+
if (node.computed || node.object.type !== "Identifier" || node.property.type !== "Identifier") return;
|
|
23
|
+
if (BANNED_MEMBERS[node.object.name]?.has(node.property.name) !== true) return;
|
|
24
|
+
const ref = sourceCode.getScope(node).references.find((r) => r.identifier === node.object);
|
|
25
|
+
if (ref?.resolved && ref.resolved.defs.length > 0) return;
|
|
26
|
+
context.report({
|
|
27
|
+
node,
|
|
28
|
+
messageId: "nondeterministic",
|
|
29
|
+
data: { what: `${node.object.name}.${node.property.name}()` }
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
NewExpression(node) {
|
|
33
|
+
if (node.callee.type === "Identifier" && node.callee.name === "Date" && node.arguments.length === 0) context.report({
|
|
34
|
+
node,
|
|
35
|
+
messageId: "nondeterministic",
|
|
36
|
+
data: { what: "new Date()" }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { noNondeterminism };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/eslint/rules/no-px-breakpoint.ts
|
|
2
|
+
const PX_BREAKPOINT = /(?<!@)\b(min|max)-\[(\d+(?:\.\d+)?)px\]:/g;
|
|
3
|
+
const ROOT_FONT_PX = 16;
|
|
4
|
+
function pxToRem(px) {
|
|
5
|
+
const rem = Number.parseFloat(px) / ROOT_FONT_PX;
|
|
6
|
+
return `${Number.parseFloat(rem.toFixed(4))}rem`;
|
|
7
|
+
}
|
|
8
|
+
const noPxBreakpoint = {
|
|
9
|
+
meta: {
|
|
10
|
+
type: "problem",
|
|
11
|
+
docs: { description: "Ban px-valued arbitrary min-width/max-width variants" },
|
|
12
|
+
schema: [],
|
|
13
|
+
messages: { pxBreakpoint: "`{{variant}}-[{{px}}px]:` is a px-valued arbitrary breakpoint — Tailwind's min-width/max-width comparator sorts by unit before number, so this silently loses the cascade to every rem-valued built-in variant (`sm:`/`md:`/`lg:`/…) regardless of which width is actually closer. Fix: write it in rem — `{{variant}}-[{{rem}}]:`." }
|
|
14
|
+
},
|
|
15
|
+
create(context) {
|
|
16
|
+
function check(node, text) {
|
|
17
|
+
for (const match of text.matchAll(PX_BREAKPOINT)) {
|
|
18
|
+
const variant = match[1] ?? "";
|
|
19
|
+
const px = match[2] ?? "";
|
|
20
|
+
context.report({
|
|
21
|
+
node,
|
|
22
|
+
messageId: "pxBreakpoint",
|
|
23
|
+
data: {
|
|
24
|
+
variant,
|
|
25
|
+
px,
|
|
26
|
+
rem: pxToRem(px)
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
Literal(node) {
|
|
34
|
+
if (typeof node.value === "string") check(node, node.value);
|
|
35
|
+
},
|
|
36
|
+
TemplateElement(node) {
|
|
37
|
+
check(node, node.value.raw);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { noPxBreakpoint };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/eslint/rules/no-raw-values.ts
|
|
2
|
+
const SLOTS = "slots";
|
|
3
|
+
function isIdentifier(node, name) {
|
|
4
|
+
return node?.type === "Identifier" && node.name === name;
|
|
5
|
+
}
|
|
6
|
+
/** `props.slots`: the base must be the identifier `props` itself. */
|
|
7
|
+
function isPropsSlots(node) {
|
|
8
|
+
return node?.type === "MemberExpression" && isIdentifier(node.property, SLOTS) && isIdentifier(node.object, "props");
|
|
9
|
+
}
|
|
10
|
+
const noRawValues = {
|
|
11
|
+
meta: {
|
|
12
|
+
type: "problem",
|
|
13
|
+
docs: { description: "Read slot values through bindings, never off a raw `slots` object" },
|
|
14
|
+
schema: [],
|
|
15
|
+
messages: { rawRead: "`{{expression}}` reads a slot value off a raw `slots` object, which skips the binding layer: the value arrives unnormalized and carries no `present`. Fix: read it through the render function's `slot` parameter (`slot.<name>.value`, `slot.<name>.present`), and use `bindItems` for a list's rows." }
|
|
16
|
+
},
|
|
17
|
+
create(context) {
|
|
18
|
+
return {
|
|
19
|
+
MemberExpression(node) {
|
|
20
|
+
const { object } = node;
|
|
21
|
+
if (isIdentifier(object, SLOTS)) context.report({
|
|
22
|
+
node,
|
|
23
|
+
messageId: "rawRead",
|
|
24
|
+
data: { expression: `${SLOTS}.…` }
|
|
25
|
+
});
|
|
26
|
+
else if (isPropsSlots(object)) context.report({
|
|
27
|
+
node,
|
|
28
|
+
messageId: "rawRead",
|
|
29
|
+
data: { expression: `props.${SLOTS}.…` }
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
VariableDeclarator(node) {
|
|
33
|
+
const { id, init } = node;
|
|
34
|
+
if (id?.type === "ObjectPattern" && isIdentifier(init, SLOTS)) context.report({
|
|
35
|
+
node,
|
|
36
|
+
messageId: "rawRead",
|
|
37
|
+
data: { expression: `{ … } = ${SLOTS}` }
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { noRawValues };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { islandImports } from "./island-imports.js";
|
|
2
|
+
import { jsxVisitor } from "./jsx-visitor.js";
|
|
3
|
+
|
|
4
|
+
//#region src/eslint/rules/serializable-props.ts
|
|
5
|
+
function inspect(node, path, out) {
|
|
6
|
+
switch (node.type) {
|
|
7
|
+
case "ArrowFunctionExpression":
|
|
8
|
+
case "FunctionExpression":
|
|
9
|
+
out.push({
|
|
10
|
+
node,
|
|
11
|
+
what: "a function",
|
|
12
|
+
path,
|
|
13
|
+
messageId: "notSerializableBadType"
|
|
14
|
+
});
|
|
15
|
+
return;
|
|
16
|
+
case "NewExpression":
|
|
17
|
+
if (node.callee?.type === "Identifier" && node.callee.name && node.callee.name !== "Object" && node.callee.name !== "Array") out.push({
|
|
18
|
+
node,
|
|
19
|
+
what: `a ${node.callee.name}`,
|
|
20
|
+
path,
|
|
21
|
+
messageId: "notSerializableClassInstance"
|
|
22
|
+
});
|
|
23
|
+
return;
|
|
24
|
+
case "ObjectExpression":
|
|
25
|
+
for (const prop of node.properties ?? []) {
|
|
26
|
+
if (prop.type !== "Property" || prop.computed === true) continue;
|
|
27
|
+
if (prop.kind !== "init") continue;
|
|
28
|
+
const key = prop.key.type === "Identifier" ? prop.key.name : prop.key.type === "Literal" ? String(prop.key.value) : void 0;
|
|
29
|
+
if (key === void 0) continue;
|
|
30
|
+
inspect(prop.value, `${path}.${key}`, out);
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
case "ArrayExpression":
|
|
34
|
+
(node.elements ?? []).forEach((element, index) => {
|
|
35
|
+
if (element && element.type !== "SpreadElement") inspect(element, `${path}[${index}]`, out);
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
case "Literal":
|
|
39
|
+
if (typeof node.bigint === "string") out.push({
|
|
40
|
+
node,
|
|
41
|
+
what: "a bigint",
|
|
42
|
+
path,
|
|
43
|
+
messageId: "notSerializableBadType"
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
case "Identifier":
|
|
47
|
+
if (node.name === "NaN" || node.name === "Infinity") out.push({
|
|
48
|
+
node,
|
|
49
|
+
what: node.name,
|
|
50
|
+
path,
|
|
51
|
+
messageId: "notSerializableNanInfinity"
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
default: return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const serializableProps = {
|
|
58
|
+
meta: {
|
|
59
|
+
type: "problem",
|
|
60
|
+
docs: { description: "Island props must be JSON-serializable" },
|
|
61
|
+
schema: [],
|
|
62
|
+
messages: {
|
|
63
|
+
notSerializableBadType: "{{path}} is {{what}} — island props must be JSON-serializable (string, number, boolean, null, plain object, array). Fix: pass data, not behavior; an island owns its own handlers.",
|
|
64
|
+
notSerializableClassInstance: "{{path}} is {{what}} — island props must be JSON-serializable (plain objects and arrays only). Fix: pass data, not behavior; a Date, Map, Set or RegExp crosses as its plain-JSON equivalent (an ISO string, say) that you reconstruct inside the island.",
|
|
65
|
+
notSerializableNanInfinity: "{{path}} is {{what}} — island props must be JSON-serializable, and JSON has no NaN or Infinity. Fix: pass a finite number, or encode the sentinel as a string prop the island parses."
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
create(context) {
|
|
69
|
+
const imports = islandImports(context);
|
|
70
|
+
return {
|
|
71
|
+
ImportDeclaration: imports.ImportDeclaration,
|
|
72
|
+
JSXOpeningElement: jsxVisitor((node) => {
|
|
73
|
+
if (node.name.type !== "JSXIdentifier" || !node.name.name || !imports.isIsland(node.name.name)) return;
|
|
74
|
+
for (const attribute of node.attributes) {
|
|
75
|
+
if (attribute.type !== "JSXAttribute" || attribute.name.type !== "JSXIdentifier" || !attribute.name.name) continue;
|
|
76
|
+
const value = attribute.value;
|
|
77
|
+
if (!value || value.type !== "JSXExpressionContainer" || !value.expression) continue;
|
|
78
|
+
const findings = [];
|
|
79
|
+
inspect(value.expression, `props.${attribute.name.name}`, findings);
|
|
80
|
+
for (const finding of findings) context.report({
|
|
81
|
+
node: finding.node,
|
|
82
|
+
messageId: finding.messageId,
|
|
83
|
+
data: {
|
|
84
|
+
path: finding.path,
|
|
85
|
+
what: finding.what
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
export { serializableProps };
|
package/dist/eslint.d.ts
ADDED
package/dist/eslint.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AUTHORING_PLUGIN_RULES, AUTHORING_RULES } from "./eslint/authoring.js";
|
|
2
|
+
import { correctnessConfig } from "./eslint/correctness.js";
|
|
3
|
+
import tsParser from "@typescript-eslint/parser";
|
|
4
|
+
|
|
5
|
+
//#region src/eslint/index.ts
|
|
6
|
+
const rules = { ...AUTHORING_PLUGIN_RULES };
|
|
7
|
+
const plugin = {
|
|
8
|
+
meta: { name: "@homepages/concrete" },
|
|
9
|
+
rules
|
|
10
|
+
};
|
|
11
|
+
const concreteConfig = [{
|
|
12
|
+
name: "concrete/authoring",
|
|
13
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
14
|
+
ignores: ["**/*.config.{ts,mts,cts,tsx}"],
|
|
15
|
+
languageOptions: {
|
|
16
|
+
parser: tsParser,
|
|
17
|
+
ecmaVersion: "latest",
|
|
18
|
+
sourceType: "module",
|
|
19
|
+
parserOptions: { ecmaFeatures: { jsx: true } }
|
|
20
|
+
},
|
|
21
|
+
plugins: { concrete: plugin },
|
|
22
|
+
rules: AUTHORING_RULES
|
|
23
|
+
}, ...correctnessConfig];
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { concreteConfig, concreteConfig as default, plugin };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/fixtures/brand.ts
|
|
2
|
+
const FIXTURE = Symbol("@homepages/concrete/fixture");
|
|
3
|
+
/** Is this export a fixture value? What the loader asks of every export of every fixture module. */
|
|
4
|
+
function isFixture(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && value[FIXTURE] === true;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { FIXTURE, isFixture };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { MEDIA_LOADERS, createFixtureMediaPlugin, externalOutsideWorkspace } from "./media-plugin.js";
|
|
2
|
+
import { FIXTURES_DIR } from "./load.js";
|
|
3
|
+
import { join, sep } from "node:path";
|
|
4
|
+
import { build } from "esbuild";
|
|
5
|
+
|
|
6
|
+
//#region src/fixtures/bundle-rule.ts
|
|
7
|
+
/** The fixtures subpath, which a shipped module may reach only as a type. */
|
|
8
|
+
const FIXTURES_SUBPATH = "@homepages/concrete/fixtures";
|
|
9
|
+
/** The sample library: copied into a workspace, never depended on. */
|
|
10
|
+
const SAMPLE_LIBRARY = "@homepages/sample-properties";
|
|
11
|
+
const RULE = "fixtures/reachable-from-bundle";
|
|
12
|
+
/**
|
|
13
|
+
* Every module reachable from `entries` that crosses into dev data, one violation per
|
|
14
|
+
* offending import, naming the importing file.
|
|
15
|
+
*/
|
|
16
|
+
async function findFixturesReachableFromBundle(options) {
|
|
17
|
+
const { root } = options;
|
|
18
|
+
const media = createFixtureMediaPlugin(root);
|
|
19
|
+
const result = await build({
|
|
20
|
+
entryPoints: [...options.entries],
|
|
21
|
+
bundle: true,
|
|
22
|
+
format: "esm",
|
|
23
|
+
platform: "node",
|
|
24
|
+
outdir: join(root, ".concrete", "cache", "bundle-probe"),
|
|
25
|
+
outbase: root,
|
|
26
|
+
absWorkingDir: root,
|
|
27
|
+
packages: "external",
|
|
28
|
+
jsx: "automatic",
|
|
29
|
+
loader: {
|
|
30
|
+
".css": "empty",
|
|
31
|
+
...MEDIA_LOADERS
|
|
32
|
+
},
|
|
33
|
+
plugins: [externalOutsideWorkspace(root), media.plugin],
|
|
34
|
+
metafile: true,
|
|
35
|
+
write: false,
|
|
36
|
+
logLevel: "silent"
|
|
37
|
+
});
|
|
38
|
+
const violations = [];
|
|
39
|
+
const fixturesPrefix = `${FIXTURES_DIR}/`;
|
|
40
|
+
for (const [input, meta] of Object.entries(result.metafile.inputs)) {
|
|
41
|
+
const file = input.split(sep).join("/");
|
|
42
|
+
if (file.startsWith(fixturesPrefix) || file.includes(":")) continue;
|
|
43
|
+
for (const imp of meta.imports) {
|
|
44
|
+
const target = imp.path.split(sep).join("/");
|
|
45
|
+
if (imp.external === true) {
|
|
46
|
+
if (target === "@homepages/concrete/fixtures") violations.push({
|
|
47
|
+
rule: RULE,
|
|
48
|
+
file,
|
|
49
|
+
message: `${file} imports ${FIXTURES_SUBPATH} as a value; only a type import may reach the fixtures subpath from shipped code`
|
|
50
|
+
});
|
|
51
|
+
else if (target === "@homepages/sample-properties" || target.startsWith(`${"@homepages/sample-properties"}/`)) violations.push({
|
|
52
|
+
rule: RULE,
|
|
53
|
+
file,
|
|
54
|
+
message: `${file} imports ${target}; the sample library is copied into a workspace with \`concrete property add\`, never depended on`
|
|
55
|
+
});
|
|
56
|
+
} else if (target.startsWith(fixturesPrefix)) violations.push({
|
|
57
|
+
rule: RULE,
|
|
58
|
+
file,
|
|
59
|
+
message: `${file} imports ${target}; nothing under ${FIXTURES_DIR}/ may be reachable from template.ts`
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return violations;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { FIXTURES_SUBPATH, SAMPLE_LIBRARY, findFixturesReachableFromBundle };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
//#region src/fixtures/canonical.d.ts
|
|
2
|
+
interface CanonicalAddress {
|
|
3
|
+
display: string;
|
|
4
|
+
street: string;
|
|
5
|
+
/** Street number + name without the type suffix ("1112 Commonwealth"). */
|
|
6
|
+
street_no_type: string;
|
|
7
|
+
city: string;
|
|
8
|
+
state: string;
|
|
9
|
+
postal: string;
|
|
10
|
+
/** Address line 2 (apt/suite/unit); absent when none. */
|
|
11
|
+
unit?: string;
|
|
12
|
+
}
|
|
13
|
+
type CanonicalPropertyType = "single_family" | "condo_townhome" | "multi_family" | "investment";
|
|
14
|
+
type CanonicalListingIntent = "for_sale" | "for_rent";
|
|
15
|
+
interface CanonicalNarrative {
|
|
16
|
+
description: string;
|
|
17
|
+
}
|
|
18
|
+
/** One 3D tour link. `provider` is a link-provider key, typed loosely on purpose. */
|
|
19
|
+
interface CanonicalTourLink {
|
|
20
|
+
id: string;
|
|
21
|
+
url: string;
|
|
22
|
+
provider: string;
|
|
23
|
+
}
|
|
24
|
+
/** One per-unit floor-plan reference; `upload_id` is a derived plan's source document. */
|
|
25
|
+
interface CanonicalUnitFloorPlanRef {
|
|
26
|
+
id: string;
|
|
27
|
+
upload_id?: string;
|
|
28
|
+
floor_label: string | null;
|
|
29
|
+
position: number;
|
|
30
|
+
}
|
|
31
|
+
interface CanonicalUnit {
|
|
32
|
+
unit_id: string;
|
|
33
|
+
unit_label: string | null;
|
|
34
|
+
beds: number;
|
|
35
|
+
baths: number;
|
|
36
|
+
sqft: number | null;
|
|
37
|
+
/** Dollars as bare digits when numeric, the verbatim text override otherwise, or null. */
|
|
38
|
+
price: string | null;
|
|
39
|
+
position: number;
|
|
40
|
+
floor_plans: CanonicalUnitFloorPlanRef[];
|
|
41
|
+
}
|
|
42
|
+
interface CanonicalPhoto {
|
|
43
|
+
id: string;
|
|
44
|
+
tags: string[];
|
|
45
|
+
caption: string | null;
|
|
46
|
+
}
|
|
47
|
+
/** One video candidate — a hosted upload or a pasted provider link; `source` is the discriminant. */
|
|
48
|
+
interface CanonicalVideo {
|
|
49
|
+
id: string;
|
|
50
|
+
source: "upload" | "link";
|
|
51
|
+
tags: string[];
|
|
52
|
+
caption: string | null;
|
|
53
|
+
description: string | null;
|
|
54
|
+
/** Null means unknown, never short. */
|
|
55
|
+
duration_ms: number | null;
|
|
56
|
+
/** Link only — the raw pasted URL. */
|
|
57
|
+
url: string | null;
|
|
58
|
+
/** Link only — a video-provider key. */
|
|
59
|
+
provider: string | null;
|
|
60
|
+
}
|
|
61
|
+
interface CanonicalDocument {
|
|
62
|
+
id: string;
|
|
63
|
+
filename: string;
|
|
64
|
+
mime: string;
|
|
65
|
+
/** The notes distilled from the file; '' where there are none. */
|
|
66
|
+
notes: string;
|
|
67
|
+
}
|
|
68
|
+
interface CanonicalFloorPlanUnitAssignment {
|
|
69
|
+
unit_label: string | null;
|
|
70
|
+
floor_label: string | null;
|
|
71
|
+
position: number;
|
|
72
|
+
}
|
|
73
|
+
interface CanonicalFloorPlan {
|
|
74
|
+
id: string;
|
|
75
|
+
upload_id?: string;
|
|
76
|
+
page_index?: number;
|
|
77
|
+
unit_assignments: CanonicalFloorPlanUnitAssignment[];
|
|
78
|
+
/** The served image key. */
|
|
79
|
+
processed_s3_key: string | null;
|
|
80
|
+
}
|
|
81
|
+
interface CanonicalContactCard {
|
|
82
|
+
id: string;
|
|
83
|
+
primary: boolean;
|
|
84
|
+
name: string | null;
|
|
85
|
+
title: string | null;
|
|
86
|
+
org_name: string | null;
|
|
87
|
+
bio: string | null;
|
|
88
|
+
email: string | null;
|
|
89
|
+
phone: string | null;
|
|
90
|
+
address: string | null;
|
|
91
|
+
website_url: string | null;
|
|
92
|
+
avatar_upload_id: string | null;
|
|
93
|
+
logo_dark_upload_id: string | null;
|
|
94
|
+
logo_light_upload_id: string | null;
|
|
95
|
+
instagram_url: string | null;
|
|
96
|
+
linkedin_url: string | null;
|
|
97
|
+
x_url: string | null;
|
|
98
|
+
facebook_url: string | null;
|
|
99
|
+
}
|
|
100
|
+
type CanonicalComparableStatus = "sold" | "active";
|
|
101
|
+
type CanonicalComparablePricePeriod = "total" | "monthly";
|
|
102
|
+
interface CanonicalComparable {
|
|
103
|
+
id: string;
|
|
104
|
+
address_street: string | null;
|
|
105
|
+
address_city: string | null;
|
|
106
|
+
address_state: string | null;
|
|
107
|
+
address_postal: string | null;
|
|
108
|
+
/** The display line, '' when no address part is set. */
|
|
109
|
+
address: string;
|
|
110
|
+
lat: number | null;
|
|
111
|
+
lng: number | null;
|
|
112
|
+
distance_m: number | null;
|
|
113
|
+
status: CanonicalComparableStatus | null;
|
|
114
|
+
/** One integer in dollars; `status` and `price_period` say what it means. */
|
|
115
|
+
price: number | null;
|
|
116
|
+
price_period: CanonicalComparablePricePeriod;
|
|
117
|
+
/** ISO `YYYY-MM-DD`; null unless sold. */
|
|
118
|
+
sale_date: string | null;
|
|
119
|
+
beds: number | null;
|
|
120
|
+
baths: number | null;
|
|
121
|
+
sqft: number | null;
|
|
122
|
+
photo_url: string | null;
|
|
123
|
+
source_url: string | null;
|
|
124
|
+
source_name: string | null;
|
|
125
|
+
}
|
|
126
|
+
interface CanonicalDocumentNote {
|
|
127
|
+
upload_id: string;
|
|
128
|
+
notes: string;
|
|
129
|
+
}
|
|
130
|
+
/** The platform's property facts, as the platform projects them. */
|
|
131
|
+
interface CanonicalProperty {
|
|
132
|
+
address: CanonicalAddress;
|
|
133
|
+
lat: number | null;
|
|
134
|
+
lon: number | null;
|
|
135
|
+
property_type: CanonicalPropertyType;
|
|
136
|
+
listing_intent: CanonicalListingIntent;
|
|
137
|
+
units: CanonicalUnit[];
|
|
138
|
+
narrative: CanonicalNarrative;
|
|
139
|
+
photos: CanonicalPhoto[];
|
|
140
|
+
videos: CanonicalVideo[];
|
|
141
|
+
floor_plans: CanonicalFloorPlan[];
|
|
142
|
+
tours: CanonicalTourLink[];
|
|
143
|
+
document_notes: CanonicalDocumentNote[];
|
|
144
|
+
documents: CanonicalDocument[];
|
|
145
|
+
contacts: CanonicalContactCard[];
|
|
146
|
+
comparables: CanonicalComparable[];
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { CanonicalAddress, CanonicalComparable, CanonicalComparablePricePeriod, CanonicalComparableStatus, CanonicalContactCard, CanonicalDocument, CanonicalDocumentNote, CanonicalFloorPlan, CanonicalFloorPlanUnitAssignment, CanonicalListingIntent, CanonicalNarrative, CanonicalPhoto, CanonicalProperty, CanonicalPropertyType, CanonicalTourLink, CanonicalUnit, CanonicalUnitFloorPlanRef, CanonicalVideo };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region src/fixtures/image-dimensions.ts
|
|
2
|
+
function png(bytes) {
|
|
3
|
+
if (bytes.length < 24) return null;
|
|
4
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
5
|
+
if (view.getUint32(0) !== 2303741511 || view.getUint32(4) !== 218765834) return null;
|
|
6
|
+
return {
|
|
7
|
+
width: view.getUint32(16),
|
|
8
|
+
height: view.getUint32(20)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function jpeg(bytes) {
|
|
12
|
+
if (bytes.length < 4 || bytes[0] !== 255 || bytes[1] !== 216) return null;
|
|
13
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
14
|
+
let offset = 2;
|
|
15
|
+
while (offset + 9 < bytes.length) {
|
|
16
|
+
if (bytes[offset] !== 255) return null;
|
|
17
|
+
const marker = bytes[offset + 1] ?? 0;
|
|
18
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) return {
|
|
19
|
+
height: view.getUint16(offset + 5),
|
|
20
|
+
width: view.getUint16(offset + 7)
|
|
21
|
+
};
|
|
22
|
+
offset += 2 + view.getUint16(offset + 2);
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
function webp(bytes) {
|
|
27
|
+
if (bytes.length < 30) return null;
|
|
28
|
+
const ascii = (at, n) => String.fromCharCode(...bytes.subarray(at, at + n));
|
|
29
|
+
if (ascii(0, 4) !== "RIFF" || ascii(8, 4) !== "WEBP") return null;
|
|
30
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
31
|
+
const chunk = ascii(12, 4);
|
|
32
|
+
if (chunk === "VP8 ") return {
|
|
33
|
+
width: view.getUint16(26, true) & 16383,
|
|
34
|
+
height: view.getUint16(28, true) & 16383
|
|
35
|
+
};
|
|
36
|
+
if (chunk === "VP8L") {
|
|
37
|
+
const b = view.getUint32(21, true);
|
|
38
|
+
return {
|
|
39
|
+
width: (b & 16383) + 1,
|
|
40
|
+
height: (b >> 14 & 16383) + 1
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (chunk === "VP8X") {
|
|
44
|
+
const w = bytes[24] | bytes[25] << 8 | bytes[26] << 16;
|
|
45
|
+
const h = bytes[27] | bytes[28] << 8 | bytes[29] << 16;
|
|
46
|
+
return {
|
|
47
|
+
width: w + 1,
|
|
48
|
+
height: h + 1
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
/** The size of a PNG, JPEG or WebP master, or `null` when the header is not one of those. */
|
|
54
|
+
function imageDimensions(bytes) {
|
|
55
|
+
return png(bytes) ?? jpeg(bytes) ?? webp(bytes);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { imageDimensions };
|