@monimesl/dot-renderer-react 0.1.0-alpha.8 → 1.0.0-beta.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/README.md +43 -1
- package/dist/LICENSE-PHOSPHOR +21 -21
- package/dist/_virtual/_rolldown/runtime.js +14 -0
- package/dist/_virtual/builtin_esm-external-require-react.js +9 -0
- package/dist/color.js +94 -0
- package/dist/components/amount-input.d.ts +6 -0
- package/dist/components/amount-input.js +111 -0
- package/dist/components/avatar.d.ts +6 -0
- package/dist/components/avatar.js +68 -0
- package/dist/components/box.js +56 -0
- package/dist/components/button.d.ts +6 -0
- package/dist/components/button.js +42 -0
- package/dist/components/carousel.d.ts +6 -0
- package/dist/components/carousel.js +258 -0
- package/dist/components/chip.d.ts +6 -0
- package/dist/components/chip.js +41 -0
- package/dist/components/code-input.d.ts +6 -0
- package/dist/components/code-input.js +96 -0
- package/dist/components/detail-row.d.ts +6 -0
- package/dist/components/detail-row.js +40 -0
- package/dist/components/disclosure.d.ts +6 -0
- package/dist/components/disclosure.js +76 -0
- package/dist/components/divider.d.ts +6 -0
- package/dist/components/divider.js +18 -0
- package/dist/components/empty-state.d.ts +6 -0
- package/dist/components/empty-state.js +64 -0
- package/dist/components/feedback.d.ts +8 -0
- package/dist/components/feedback.js +101 -0
- package/dist/components/field-box.js +44 -0
- package/dist/components/field.js +43 -0
- package/dist/components/footer.d.ts +6 -0
- package/dist/components/footer.js +25 -0
- package/dist/components/grid.d.ts +7 -0
- package/dist/components/grid.js +97 -0
- package/dist/components/https.js +11 -0
- package/dist/components/icon-artwork.js +143 -0
- package/dist/components/icon-button.js +28 -0
- package/dist/components/icon-svg.js +27 -0
- package/dist/components/icon.d.ts +6 -0
- package/dist/components/icon.js +25 -0
- package/dist/components/image.d.ts +6 -0
- package/dist/components/image.js +40 -0
- package/dist/components/index.d.ts +38 -0
- package/dist/components/index.js +92 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.js +108 -0
- package/dist/components/link.d.ts +6 -0
- package/dist/components/link.js +32 -0
- package/dist/components/list.d.ts +7 -0
- package/dist/components/list.js +143 -0
- package/dist/components/numbers.js +9 -0
- package/dist/components/option-place.js +9 -0
- package/dist/components/option.d.ts +6 -0
- package/dist/components/option.js +44 -0
- package/dist/components/padding.d.ts +2 -0
- package/dist/components/padding.js +38 -0
- package/dist/components/pressable.js +17 -0
- package/dist/components/prose-context.js +5 -0
- package/dist/components/prose.d.ts +9 -0
- package/dist/components/prose.js +67 -0
- package/dist/components/qr-code.d.ts +6 -0
- package/dist/components/qr-code.js +58 -0
- package/dist/components/rich-text.d.ts +6 -0
- package/dist/components/rich-text.js +73 -0
- package/dist/components/scroll.d.ts +6 -0
- package/dist/components/scroll.js +57 -0
- package/dist/components/select.d.ts +6 -0
- package/dist/components/select.js +93 -0
- package/dist/components/sheet.d.ts +8 -0
- package/dist/components/sheet.js +106 -0
- package/dist/components/skeleton.d.ts +6 -0
- package/dist/components/skeleton.js +55 -0
- package/dist/components/slider.d.ts +6 -0
- package/dist/components/slider.js +57 -0
- package/dist/components/spinner.d.ts +6 -0
- package/dist/components/spinner.js +48 -0
- package/dist/components/stack.d.ts +6 -0
- package/dist/components/stack.js +25 -0
- package/dist/components/stepper.d.ts +6 -0
- package/dist/components/stepper.js +92 -0
- package/dist/components/steps.d.ts +7 -0
- package/dist/components/steps.js +110 -0
- package/dist/components/tabs.d.ts +7 -0
- package/dist/components/tabs.js +95 -0
- package/dist/components/text-area.d.ts +6 -0
- package/dist/components/text-area.js +42 -0
- package/dist/components/text.d.ts +6 -0
- package/dist/components/text.js +107 -0
- package/dist/components/toast.d.ts +6 -0
- package/dist/components/toast.js +56 -0
- package/dist/components/toggles.d.ts +9 -0
- package/dist/components/toggles.js +148 -0
- package/dist/components/tokens.js +49 -0
- package/dist/components/tones.js +30 -0
- package/dist/components/typed-text.js +28 -0
- package/dist/components/view.d.ts +6 -0
- package/dist/components/view.js +61 -0
- package/dist/index.d.ts +43 -64
- package/dist/index.js +40 -22636
- package/dist/markdown.js +255 -0
- package/dist/page-root.d.ts +2 -0
- package/dist/page-root.js +20 -0
- package/dist/portal.js +8 -0
- package/dist/pull-to-refresh.js +120 -0
- package/dist/renderer.d.ts +17 -0
- package/dist/renderer.js +33 -0
- package/dist/root.d.ts +10 -0
- package/dist/root.js +71 -0
- package/dist/styles.css +1 -1
- package/dist/theme.d.ts +26 -0
- package/dist/theme.js +129 -0
- package/dist/types.d.ts +7 -0
- package/dist/vendor/@base-ui/react/checkbox/indicator/CheckboxIndicator.js +51 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRoot.js +265 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/checkbox/utils/getCheckboxStateAttributesMapping.js +15 -0
- package/dist/vendor/@base-ui/react/checkbox-group/CheckboxGroupContext.js +10 -0
- package/dist/vendor/@base-ui/react/dialog/backdrop/DialogBackdrop.js +40 -0
- package/dist/vendor/@base-ui/react/dialog/close/DialogClose.js +39 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopup.js +92 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupCssVars.js +8 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupDataAttributes.js +7 -0
- package/dist/vendor/@base-ui/react/dialog/portal/DialogPortal.js +38 -0
- package/dist/vendor/@base-ui/react/dialog/portal/DialogPortalContext.js +13 -0
- package/dist/vendor/@base-ui/react/dialog/root/DialogRoot.js +16 -0
- package/dist/vendor/@base-ui/react/dialog/root/DialogRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/dialog/root/useDialogRoot.js +77 -0
- package/dist/vendor/@base-ui/react/dialog/root/useRenderDialogRoot.js +65 -0
- package/dist/vendor/@base-ui/react/dialog/store/DialogStore.js +70 -0
- package/dist/vendor/@base-ui/react/dialog/title/DialogTitle.js +25 -0
- package/dist/vendor/@base-ui/react/dialog/utils/stateAttributesMapping.js +17 -0
- package/dist/vendor/@base-ui/react/field/control/FieldControlDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/field/item/FieldItemContext.js +10 -0
- package/dist/vendor/@base-ui/react/field/root/useFieldValidation.js +18 -0
- package/dist/vendor/@base-ui/react/fieldset/root/FieldsetRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingFocusManager.js +477 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingPortal.js +165 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingRootStore.js +65 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingTree.js +22 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useDismiss.js +373 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.js +58 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/composite.js +40 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/constants.js +5 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/createAttribute.js +6 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/createEventEmitter.js +18 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/element.js +26 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/enqueueFocus.js +25 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/event.js +25 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/markOthers.js +116 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/nodes.js +16 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/tabbable.js +135 -0
- package/dist/vendor/@base-ui/react/internals/TransitionStatusDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/internals/composite/composite.js +89 -0
- package/dist/vendor/@base-ui/react/internals/composite/constants.js +4 -0
- package/dist/vendor/@base-ui/react/internals/composite/item/CompositeItem.js +21 -0
- package/dist/vendor/@base-ui/react/internals/composite/item/useCompositeItem.js +31 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/CompositeList.js +180 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/CompositeListContext.js +15 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/useCompositeListItem.js +54 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRoot.js +62 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/useCompositeRoot.js +170 -0
- package/dist/vendor/@base-ui/react/internals/constants.js +18 -0
- package/dist/vendor/@base-ui/react/internals/createBaseUIEventDetails.js +40 -0
- package/dist/vendor/@base-ui/react/internals/direction-context/DirectionContext.js +10 -0
- package/dist/vendor/@base-ui/react/internals/field-constants/constants.js +33 -0
- package/dist/vendor/@base-ui/react/internals/field-register-control/useRegisterFieldControl.js +40 -0
- package/dist/vendor/@base-ui/react/internals/field-root-context/FieldRootContext.js +45 -0
- package/dist/vendor/@base-ui/react/internals/form-context/FormContext.js +18 -0
- package/dist/vendor/@base-ui/react/internals/getStateAttributesProps.js +17 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/LabelableContext.js +24 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/useAriaLabelledBy.js +35 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/useLabelableId.js +57 -0
- package/dist/vendor/@base-ui/react/internals/reason-parts.js +14 -0
- package/dist/vendor/@base-ui/react/internals/serializeValue.js +12 -0
- package/dist/vendor/@base-ui/react/internals/stateAttributesMapping.js +11 -0
- package/dist/vendor/@base-ui/react/internals/use-button/useButton.js +137 -0
- package/dist/vendor/@base-ui/react/internals/useAnimationsFinished.js +94 -0
- package/dist/vendor/@base-ui/react/internals/useBaseUiId.js +13 -0
- package/dist/vendor/@base-ui/react/internals/useOpenChangeComplete.js +28 -0
- package/dist/vendor/@base-ui/react/internals/useRenderElement.js +109 -0
- package/dist/vendor/@base-ui/react/internals/useTransitionStatus.js +70 -0
- package/dist/vendor/@base-ui/react/internals/useValueChanged.js +15 -0
- package/dist/vendor/@base-ui/react/merge-props/mergeProps.js +153 -0
- package/dist/vendor/@base-ui/react/radio/indicator/RadioIndicator.js +46 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRoot.js +179 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/radio/utils/stateAttributesMapping.js +14 -0
- package/dist/vendor/@base-ui/react/radio-group/RadioGroup.js +170 -0
- package/dist/vendor/@base-ui/react/radio-group/RadioGroupContext.js +10 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRoot.js +170 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/switch/stateAttributesMapping.js +12 -0
- package/dist/vendor/@base-ui/react/switch/thumb/SwitchThumb.js +25 -0
- package/dist/vendor/@base-ui/react/tabs/list/TabsList.js +98 -0
- package/dist/vendor/@base-ui/react/tabs/list/TabsListContext.js +13 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRoot.js +213 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRootContext.js +16 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRootDataAttributes.js +8 -0
- package/dist/vendor/@base-ui/react/tabs/root/stateAttributesMapping.js +5 -0
- package/dist/vendor/@base-ui/react/tabs/tab/TabsTab.js +137 -0
- package/dist/vendor/@base-ui/react/utils/CommonPopupDataAttributes.js +24 -0
- package/dist/vendor/@base-ui/react/utils/CommonTriggerDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/utils/FocusGuard.js +32 -0
- package/dist/vendor/@base-ui/react/utils/InternalBackdrop.js +30 -0
- package/dist/vendor/@base-ui/react/utils/dispatchClickWithModifiers.js +25 -0
- package/dist/vendor/@base-ui/react/utils/popupStateMapping.js +22 -0
- package/dist/vendor/@base-ui/react/utils/popups/popupStoreUtils.js +247 -0
- package/dist/vendor/@base-ui/react/utils/popups/popupTriggerMap.js +96 -0
- package/dist/vendor/@base-ui/react/utils/popups/store.js +94 -0
- package/dist/vendor/@base-ui/react/utils/resolveClassName.js +13 -0
- package/dist/vendor/@base-ui/react/utils/resolveRef.js +11 -0
- package/dist/vendor/@base-ui/react/utils/resolveStyle.js +13 -0
- package/dist/vendor/@base-ui/react/utils/useFocusableWhenDisabled.js +30 -0
- package/dist/vendor/@base-ui/utils/addEventListener.js +12 -0
- package/dist/vendor/@base-ui/utils/createLogOnce.js +20 -0
- package/dist/vendor/@base-ui/utils/empty.js +6 -0
- package/dist/vendor/@base-ui/utils/error.js +5 -0
- package/dist/vendor/@base-ui/utils/fastHooks.js +68 -0
- package/dist/vendor/@base-ui/utils/formatErrorMessage.js +27 -0
- package/dist/vendor/@base-ui/utils/getDefaultFormSubmitter.js +25 -0
- package/dist/vendor/@base-ui/utils/getReactElementRef.js +14 -0
- package/dist/vendor/@base-ui/utils/inertValue.js +8 -0
- package/dist/vendor/@base-ui/utils/isElementDisabled.js +6 -0
- package/dist/vendor/@base-ui/utils/mergeCleanups.js +14 -0
- package/dist/vendor/@base-ui/utils/mergeObjects.js +11 -0
- package/dist/vendor/@base-ui/utils/owner.js +7 -0
- package/dist/vendor/@base-ui/utils/platform/engine.js +8 -0
- package/dist/vendor/@base-ui/utils/platform/env.js +6 -0
- package/dist/vendor/@base-ui/utils/platform/os.js +15 -0
- package/dist/vendor/@base-ui/utils/platform/screen-reader.js +9 -0
- package/dist/vendor/@base-ui/utils/platform/shared.js +36 -0
- package/dist/vendor/@base-ui/utils/reactVersion.js +8 -0
- package/dist/vendor/@base-ui/utils/safeReact.js +13 -0
- package/dist/vendor/@base-ui/utils/shadowDom.js +26 -0
- package/dist/vendor/@base-ui/utils/store/ReactStore.js +181 -0
- package/dist/vendor/@base-ui/utils/store/Store.js +102 -0
- package/dist/vendor/@base-ui/utils/store/useStore.js +97 -0
- package/dist/vendor/@base-ui/utils/useAnimationFrame.js +87 -0
- package/dist/vendor/@base-ui/utils/useControlled.js +52 -0
- package/dist/vendor/@base-ui/utils/useId.js +32 -0
- package/dist/vendor/@base-ui/utils/useIsoLayoutEffect.js +7 -0
- package/dist/vendor/@base-ui/utils/useMergedRefs.js +87 -0
- package/dist/vendor/@base-ui/utils/useOnMount.js +12 -0
- package/dist/vendor/@base-ui/utils/useRefWithInit.js +18 -0
- package/dist/vendor/@base-ui/utils/useScrollLock.js +206 -0
- package/dist/vendor/@base-ui/utils/useStableCallback.js +38 -0
- package/dist/vendor/@base-ui/utils/useTimeout.js +43 -0
- package/dist/vendor/@base-ui/utils/useValueAsRef.js +27 -0
- package/dist/vendor/@base-ui/utils/visuallyHidden.js +23 -0
- package/dist/vendor/@base-ui/utils/warn.js +5 -0
- package/dist/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js +49 -0
- package/dist/vendor/uqr/dist/index.js +858 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +74 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +77 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +69 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +64 -0
- package/dist/vendor/use-sync-external-store/shim/index.js +11 -0
- package/dist/vendor/use-sync-external-store/shim/with-selector.js +11 -0
- package/package.json +10 -15
- package/dist/garra-versions.json +0 -7
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
//#region src/markdown.ts
|
|
2
|
+
const HEADING = /^(#{1,6})\s+(.*)$/;
|
|
3
|
+
const RULE = /^ {0,3}([-*_])( *\1){2,} *$/;
|
|
4
|
+
const QUOTE = /^ {0,3}> ?/;
|
|
5
|
+
const LIST_ITEM = /^ {0,3}([-*+]|\d{1,9}[.)])\s+/;
|
|
6
|
+
const LINK = /^(!?)\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/;
|
|
7
|
+
const AUTOLINK = /^<(https?:\/\/[^>\s]+)>/;
|
|
8
|
+
const PUNCTUATION = /[!-/:-@[-`{-~]/;
|
|
9
|
+
const ITEM_INDENT = " ";
|
|
10
|
+
const MAX_INLINE_LENGTH = 2e4;
|
|
11
|
+
function parseMarkdown(markdown) {
|
|
12
|
+
return parseBlocks(markdown.replace(/\r\n?/g, "\n").split("\n"));
|
|
13
|
+
}
|
|
14
|
+
function parseBlocks(lines) {
|
|
15
|
+
const blocks = [];
|
|
16
|
+
let index = 0;
|
|
17
|
+
while (index < lines.length) {
|
|
18
|
+
const line = lines[index];
|
|
19
|
+
if (line.trim() === "") {
|
|
20
|
+
index += 1;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const single = oneLineBlock(line);
|
|
24
|
+
if (single) {
|
|
25
|
+
blocks.push(single);
|
|
26
|
+
index += 1;
|
|
27
|
+
} else if (QUOTE.test(line)) {
|
|
28
|
+
const quoted = [];
|
|
29
|
+
while (index < lines.length && QUOTE.test(lines[index])) {
|
|
30
|
+
quoted.push(lines[index].replace(QUOTE, ""));
|
|
31
|
+
index += 1;
|
|
32
|
+
}
|
|
33
|
+
blocks.push({
|
|
34
|
+
kind: "quote",
|
|
35
|
+
blocks: parseBlocks(quoted)
|
|
36
|
+
});
|
|
37
|
+
} else if (LIST_ITEM.test(line)) {
|
|
38
|
+
const { list, next } = parseList(lines, index);
|
|
39
|
+
blocks.push(list);
|
|
40
|
+
index = next;
|
|
41
|
+
} else {
|
|
42
|
+
const paragraph = [];
|
|
43
|
+
while (index < lines.length && !endsParagraph(lines[index])) {
|
|
44
|
+
paragraph.push(lines[index]);
|
|
45
|
+
index += 1;
|
|
46
|
+
}
|
|
47
|
+
blocks.push({
|
|
48
|
+
kind: "paragraph",
|
|
49
|
+
content: parseInline(joinLines(paragraph))
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return blocks;
|
|
54
|
+
}
|
|
55
|
+
function oneLineBlock(line) {
|
|
56
|
+
const heading = HEADING.exec(line);
|
|
57
|
+
if (heading) return {
|
|
58
|
+
kind: "heading",
|
|
59
|
+
level: Math.min(heading[1].length, 3),
|
|
60
|
+
content: parseInline(withoutClosingHashes(heading[2]))
|
|
61
|
+
};
|
|
62
|
+
if (RULE.test(line)) return { kind: "rule" };
|
|
63
|
+
const trimmed = line.trim();
|
|
64
|
+
const picture = LINK.exec(trimmed);
|
|
65
|
+
if (picture && picture[1] === "!" && picture[0].length === trimmed.length) return {
|
|
66
|
+
kind: "image",
|
|
67
|
+
alt: picture[2],
|
|
68
|
+
src: picture[3]
|
|
69
|
+
};
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function withoutClosingHashes(text) {
|
|
73
|
+
let end = text.trimEnd().length;
|
|
74
|
+
while (end > 0 && text[end - 1] === "#") end -= 1;
|
|
75
|
+
return text.slice(0, end).trimEnd();
|
|
76
|
+
}
|
|
77
|
+
function endsParagraph(line) {
|
|
78
|
+
return line.trim() === "" || HEADING.test(line) || RULE.test(line) || QUOTE.test(line) || LIST_ITEM.test(line);
|
|
79
|
+
}
|
|
80
|
+
function joinLines(lines) {
|
|
81
|
+
let text = "";
|
|
82
|
+
lines.forEach((line, index) => {
|
|
83
|
+
text += line.trim().replace(/\\$/, "");
|
|
84
|
+
if (index < lines.length - 1) text += /( {2,}|\\)$/.test(line) ? "\n" : " ";
|
|
85
|
+
});
|
|
86
|
+
return text;
|
|
87
|
+
}
|
|
88
|
+
function parseList(lines, start) {
|
|
89
|
+
const ordered = isOrdered(LIST_ITEM.exec(lines[start]));
|
|
90
|
+
const items = [];
|
|
91
|
+
let index = start;
|
|
92
|
+
while (index < lines.length) {
|
|
93
|
+
const marker = LIST_ITEM.exec(lines[index]);
|
|
94
|
+
if (!marker || isOrdered(marker) !== ordered) break;
|
|
95
|
+
const indent = marker[0].length;
|
|
96
|
+
const itemLines = [lines[index].slice(indent)];
|
|
97
|
+
index += 1;
|
|
98
|
+
while (index < lines.length) {
|
|
99
|
+
const line = lines[index];
|
|
100
|
+
if (line.trim() === "") {
|
|
101
|
+
if (!lines[index + 1]?.startsWith(ITEM_INDENT)) break;
|
|
102
|
+
itemLines.push("");
|
|
103
|
+
} else if (line.startsWith(ITEM_INDENT)) itemLines.push(withoutIndent(line, indent));
|
|
104
|
+
else if (endsParagraph(line)) break;
|
|
105
|
+
else itemLines.push(line);
|
|
106
|
+
index += 1;
|
|
107
|
+
}
|
|
108
|
+
items.push(parseBlocks(itemLines));
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
list: {
|
|
112
|
+
kind: "list",
|
|
113
|
+
ordered,
|
|
114
|
+
items
|
|
115
|
+
},
|
|
116
|
+
next: index
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function isOrdered(marker) {
|
|
120
|
+
return /\d/.test(marker[1]);
|
|
121
|
+
}
|
|
122
|
+
function withoutIndent(line, indent) {
|
|
123
|
+
const spaces = line.length - line.trimStart().length;
|
|
124
|
+
return line.slice(Math.min(spaces, indent));
|
|
125
|
+
}
|
|
126
|
+
function parseInline(text) {
|
|
127
|
+
if (text.length > MAX_INLINE_LENGTH) return [{
|
|
128
|
+
kind: "text",
|
|
129
|
+
text
|
|
130
|
+
}];
|
|
131
|
+
const inlines = [];
|
|
132
|
+
const closingSearches = /* @__PURE__ */ new Map();
|
|
133
|
+
let plain = "";
|
|
134
|
+
let index = 0;
|
|
135
|
+
const flush = () => {
|
|
136
|
+
if (plain) {
|
|
137
|
+
inlines.push({
|
|
138
|
+
kind: "text",
|
|
139
|
+
text: plain
|
|
140
|
+
});
|
|
141
|
+
plain = "";
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const take = (inline, length) => {
|
|
145
|
+
flush();
|
|
146
|
+
inlines.push(inline);
|
|
147
|
+
index += length;
|
|
148
|
+
};
|
|
149
|
+
while (index < text.length) {
|
|
150
|
+
const char = text[index];
|
|
151
|
+
const next = text[index + 1];
|
|
152
|
+
const rest = text.slice(index);
|
|
153
|
+
if (char === "\\" && next !== void 0 && PUNCTUATION.test(next)) {
|
|
154
|
+
plain += next;
|
|
155
|
+
index += 2;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (char === "\n") {
|
|
159
|
+
take({ kind: "break" }, 1);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (char === "`") {
|
|
163
|
+
const codeEnd = text.indexOf("`", index + 1);
|
|
164
|
+
if (codeEnd > index + 1) {
|
|
165
|
+
take({
|
|
166
|
+
kind: "code",
|
|
167
|
+
text: text.slice(index + 1, codeEnd)
|
|
168
|
+
}, codeEnd + 1 - index);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const link = LINK.exec(rest);
|
|
173
|
+
if (link) {
|
|
174
|
+
const [whole, picture, label, href] = link;
|
|
175
|
+
take(picture === "!" ? {
|
|
176
|
+
kind: "text",
|
|
177
|
+
text: label
|
|
178
|
+
} : {
|
|
179
|
+
kind: "link",
|
|
180
|
+
href,
|
|
181
|
+
children: parseInline(label)
|
|
182
|
+
}, whole.length);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const autolink = AUTOLINK.exec(rest);
|
|
186
|
+
if (autolink) {
|
|
187
|
+
const [whole, href] = autolink;
|
|
188
|
+
take({
|
|
189
|
+
kind: "link",
|
|
190
|
+
href,
|
|
191
|
+
children: [{
|
|
192
|
+
kind: "text",
|
|
193
|
+
text: href
|
|
194
|
+
}]
|
|
195
|
+
}, whole.length);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (char === "*" || char === "_") {
|
|
199
|
+
const strong = between(text, index, char + char, closingSearches);
|
|
200
|
+
if (strong) {
|
|
201
|
+
take({
|
|
202
|
+
kind: "strong",
|
|
203
|
+
children: parseInline(strong.inner)
|
|
204
|
+
}, strong.length);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const emphasis = between(text, index, char, closingSearches);
|
|
208
|
+
if (emphasis) {
|
|
209
|
+
take({
|
|
210
|
+
kind: "emphasis",
|
|
211
|
+
children: parseInline(emphasis.inner)
|
|
212
|
+
}, emphasis.length);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
plain += char;
|
|
217
|
+
index += 1;
|
|
218
|
+
}
|
|
219
|
+
flush();
|
|
220
|
+
return inlines;
|
|
221
|
+
}
|
|
222
|
+
function between(text, start, delimiter, closingSearches) {
|
|
223
|
+
const open = start + delimiter.length;
|
|
224
|
+
if (!text.startsWith(delimiter, start) || open >= text.length || /\s/.test(text[open])) return null;
|
|
225
|
+
const underscore = delimiter.startsWith("_");
|
|
226
|
+
if (underscore && /\w/.test(text[start - 1] ?? "")) return null;
|
|
227
|
+
let searchEnds = closingSearches.get(delimiter);
|
|
228
|
+
if (!searchEnds) {
|
|
229
|
+
searchEnds = /* @__PURE__ */ new Map();
|
|
230
|
+
closingSearches.set(delimiter, searchEnds);
|
|
231
|
+
}
|
|
232
|
+
const placesLookedAt = [];
|
|
233
|
+
let close = text.indexOf(delimiter, open + 1);
|
|
234
|
+
while (close !== -1) {
|
|
235
|
+
const earlierEnd = searchEnds.get(close);
|
|
236
|
+
if (earlierEnd !== void 0) {
|
|
237
|
+
close = earlierEnd;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
placesLookedAt.push(close);
|
|
241
|
+
const touchesSpace = /\s/.test(text[close - 1]);
|
|
242
|
+
const insideWord = underscore && /\w/.test(text[close + delimiter.length] ?? "");
|
|
243
|
+
const startsPair = delimiter.length === 1 && text[close + 1] === delimiter;
|
|
244
|
+
if (!touchesSpace && !insideWord && !startsPair) break;
|
|
245
|
+
close = text.indexOf(delimiter, close + (startsPair ? 2 : 1));
|
|
246
|
+
}
|
|
247
|
+
for (const place of placesLookedAt) searchEnds.set(place, close);
|
|
248
|
+
if (close === -1) return null;
|
|
249
|
+
return {
|
|
250
|
+
inner: text.slice(open, close),
|
|
251
|
+
length: close + delimiter.length - start
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
export { parseInline, parseMarkdown };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { toList, toText } from "@monimesl/dot-core";
|
|
2
|
+
import { Fragment, createElement, useMemo, useSyncExternalStore } from "react";
|
|
3
|
+
//#region src/page-root.tsx
|
|
4
|
+
function PageRoot({ page, components }) {
|
|
5
|
+
const state = useSyncExternalStore(page.subscribe, page.getState);
|
|
6
|
+
const context = useMemo(() => ({
|
|
7
|
+
h(type, props, ...children) {
|
|
8
|
+
const component = components[type];
|
|
9
|
+
if (!component) throw new Error(`The renderer has no component for <${type}>. Check the tag's name, or pass a component for it to the renderer.`);
|
|
10
|
+
return createElement(component, props, ...children);
|
|
11
|
+
},
|
|
12
|
+
text: toText,
|
|
13
|
+
on: (handler, data) => page.on(handler, data),
|
|
14
|
+
each: (items, render, key) => createElement(Fragment, null, toList(items).map((item, index) => createElement(Fragment, { key: key ? String(key(item, index)) : index }, ...render(item, index))))
|
|
15
|
+
}), [page, components]);
|
|
16
|
+
if (!state) return null;
|
|
17
|
+
return page.viewRenderer(state, context);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { PageRoot };
|
package/dist/portal.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
//#region src/portal.ts
|
|
3
|
+
const PortalContainerContext = createContext(null);
|
|
4
|
+
function usePortalContainer() {
|
|
5
|
+
return useContext(PortalContainerContext) ?? void 0;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { PortalContainerContext, usePortalContainer };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useTheme } from "./theme.js";
|
|
2
|
+
import { CENTERED } from "./components/tokens.js";
|
|
3
|
+
import { LoadingIcon } from "./components/spinner.js";
|
|
4
|
+
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/pull-to-refresh.tsx
|
|
7
|
+
const PULL_DISTANCE = 64;
|
|
8
|
+
const LONGEST_PULL = PULL_DISTANCE * 1.5;
|
|
9
|
+
const RESISTANCE = .5;
|
|
10
|
+
const INDICATOR_SIZE = 36;
|
|
11
|
+
const DRAG_DISTANCE = 6;
|
|
12
|
+
function PullToRefresh({ page, children }) {
|
|
13
|
+
const { colors } = useTheme();
|
|
14
|
+
const refreshing = useSyncExternalStore(page.subscribeToRefreshing, page.isRefreshing);
|
|
15
|
+
const [pullDistance, setPullDistance] = useState(0);
|
|
16
|
+
const areaRef = useRef(null);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const area = areaRef.current;
|
|
19
|
+
const view = area.ownerDocument.defaultView;
|
|
20
|
+
let startY;
|
|
21
|
+
let pulled = 0;
|
|
22
|
+
let dragged = false;
|
|
23
|
+
const begin = (y) => {
|
|
24
|
+
const atTop = view.scrollY <= 0;
|
|
25
|
+
startY = page.refreshable && atTop && !page.isRefreshing() ? y : void 0;
|
|
26
|
+
dragged = false;
|
|
27
|
+
};
|
|
28
|
+
const move = (y, event) => {
|
|
29
|
+
if (startY === void 0) return;
|
|
30
|
+
const distance = (y - startY) * RESISTANCE;
|
|
31
|
+
if (distance <= 0) {
|
|
32
|
+
pulled = 0;
|
|
33
|
+
setPullDistance(0);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (event.cancelable) event.preventDefault();
|
|
37
|
+
if (distance > DRAG_DISTANCE) dragged = true;
|
|
38
|
+
pulled = Math.min(distance, LONGEST_PULL);
|
|
39
|
+
setPullDistance(pulled);
|
|
40
|
+
};
|
|
41
|
+
const end = () => {
|
|
42
|
+
if (startY !== void 0 && pulled >= PULL_DISTANCE) page.refresh();
|
|
43
|
+
startY = void 0;
|
|
44
|
+
pulled = 0;
|
|
45
|
+
setPullDistance(0);
|
|
46
|
+
};
|
|
47
|
+
const ignoreDragClick = (event) => {
|
|
48
|
+
if (dragged) {
|
|
49
|
+
dragged = false;
|
|
50
|
+
event.stopPropagation();
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const touchStart = (event) => begin(event.touches[0].clientY);
|
|
55
|
+
const touchMove = (event) => move(event.touches[0].clientY, event);
|
|
56
|
+
const mouseDown = (event) => {
|
|
57
|
+
if (event.button === 0) begin(event.clientY);
|
|
58
|
+
};
|
|
59
|
+
const mouseMove = (event) => move(event.clientY, event);
|
|
60
|
+
const removeListeners = [
|
|
61
|
+
listen(area, "touchstart", touchStart, { passive: true }),
|
|
62
|
+
listen(area, "touchmove", touchMove, { passive: false }),
|
|
63
|
+
listen(area, "touchend", end),
|
|
64
|
+
listen(area, "touchcancel", end),
|
|
65
|
+
listen(area, "mousedown", mouseDown),
|
|
66
|
+
listen(area, "click", ignoreDragClick, { capture: true }),
|
|
67
|
+
listen(view, "mousemove", mouseMove),
|
|
68
|
+
listen(view, "mouseup", end)
|
|
69
|
+
];
|
|
70
|
+
return () => {
|
|
71
|
+
for (const removeListener of removeListeners) removeListener();
|
|
72
|
+
};
|
|
73
|
+
}, [page]);
|
|
74
|
+
const indicatorDistance = refreshing ? PULL_DISTANCE : pullDistance;
|
|
75
|
+
const arrowTurn = Math.min(pullDistance, PULL_DISTANCE) / PULL_DISTANCE * 180;
|
|
76
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
77
|
+
ref: areaRef,
|
|
78
|
+
className: "dot-pull-to-refresh",
|
|
79
|
+
style: { display: "contents" },
|
|
80
|
+
children: [children, indicatorDistance > 0 ? /* @__PURE__ */ jsx("span", {
|
|
81
|
+
role: refreshing ? "status" : void 0,
|
|
82
|
+
"aria-label": refreshing ? "Refreshing" : void 0,
|
|
83
|
+
style: {
|
|
84
|
+
position: "fixed",
|
|
85
|
+
top: 0,
|
|
86
|
+
left: "50%",
|
|
87
|
+
zIndex: 2,
|
|
88
|
+
...CENTERED,
|
|
89
|
+
width: INDICATOR_SIZE,
|
|
90
|
+
height: INDICATOR_SIZE,
|
|
91
|
+
marginLeft: -18,
|
|
92
|
+
borderRadius: "50%",
|
|
93
|
+
background: colors.surface,
|
|
94
|
+
color: colors.primary,
|
|
95
|
+
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.2)",
|
|
96
|
+
transform: `translateY(${indicatorDistance - INDICATOR_SIZE / 2}px)`,
|
|
97
|
+
transition: pullDistance > 0 ? "none" : "transform 0.2s",
|
|
98
|
+
pointerEvents: "none"
|
|
99
|
+
},
|
|
100
|
+
children: refreshing ? /* @__PURE__ */ jsx(LoadingIcon, { size: 20 }) : /* @__PURE__ */ jsx("svg", {
|
|
101
|
+
width: 20,
|
|
102
|
+
height: 20,
|
|
103
|
+
viewBox: "0 0 24 24",
|
|
104
|
+
fill: "none",
|
|
105
|
+
stroke: "currentColor",
|
|
106
|
+
strokeWidth: 2.5,
|
|
107
|
+
strokeLinecap: "round",
|
|
108
|
+
strokeLinejoin: "round",
|
|
109
|
+
style: { transform: `rotate(${arrowTurn}deg)` },
|
|
110
|
+
children: /* @__PURE__ */ jsx("path", { d: "M12 5v14M6 13l6 6 6-6" })
|
|
111
|
+
})
|
|
112
|
+
}) : null]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function listen(target, type, listener, options) {
|
|
116
|
+
target.addEventListener(type, listener, options);
|
|
117
|
+
return () => target.removeEventListener(type, listener, options);
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { PullToRefresh };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Wrapper } from "./root.js";
|
|
2
|
+
import { BuiltinReactComponents } from "./types.js";
|
|
3
|
+
import { JSXElementConstructor } from "react";
|
|
4
|
+
import { Renderer } from "@monimesl/dot-webview";
|
|
5
|
+
//#region src/renderer.d.ts
|
|
6
|
+
type ComponentImplementations = Readonly<Record<string, JSXElementConstructor<never>>>;
|
|
7
|
+
export interface ReactRendererOptions {
|
|
8
|
+
components?: Partial<BuiltinReactComponents> & ComponentImplementations;
|
|
9
|
+
wrapper?: Wrapper | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateReactRendererOptions {
|
|
12
|
+
components: ComponentImplementations;
|
|
13
|
+
wrapper?: Wrapper | undefined;
|
|
14
|
+
}
|
|
15
|
+
export declare function createReactRenderer({ components, wrapper }: CreateReactRendererOptions): Renderer;
|
|
16
|
+
export declare function reactRenderer({ components, wrapper }?: ReactRendererOptions): Renderer;
|
|
17
|
+
//#endregion
|
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { components_exports } from "./components/index.js";
|
|
2
|
+
import { Root } from "./root.js";
|
|
3
|
+
import { createRoot } from "react-dom/client";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/renderer.tsx
|
|
6
|
+
const builtins = components_exports;
|
|
7
|
+
function createReactRenderer({ components, wrapper }) {
|
|
8
|
+
const registry = components;
|
|
9
|
+
return {
|
|
10
|
+
name: "react",
|
|
11
|
+
mount(container, page, dotContext) {
|
|
12
|
+
const root = createRoot(container);
|
|
13
|
+
root.render(/* @__PURE__ */ jsx(Root, {
|
|
14
|
+
page,
|
|
15
|
+
dotContext,
|
|
16
|
+
components: registry,
|
|
17
|
+
wrapper
|
|
18
|
+
}));
|
|
19
|
+
return () => root.unmount();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function reactRenderer({ components = {}, wrapper } = {}) {
|
|
24
|
+
return createReactRenderer({
|
|
25
|
+
components: {
|
|
26
|
+
...builtins,
|
|
27
|
+
...components
|
|
28
|
+
},
|
|
29
|
+
wrapper
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { createReactRenderer, reactRenderer };
|
package/dist/root.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./page-root.js";
|
|
2
|
+
import { Theme } from "@monimesl/dot-core";
|
|
3
|
+
import { ComponentType, ReactNode } from "react";
|
|
4
|
+
import "@monimesl/dot-webview";
|
|
5
|
+
//#region src/root.d.ts
|
|
6
|
+
export type Wrapper = ComponentType<{
|
|
7
|
+
theme: Theme;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
//#endregion
|
package/dist/root.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { FONT_FAMILY, ThemeContext, resolveTheme, useTheme } from "./theme.js";
|
|
2
|
+
import { HOME_INDICATOR } from "./components/padding.js";
|
|
3
|
+
import { PortalContainerContext } from "./portal.js";
|
|
4
|
+
import { PageRoot } from "./page-root.js";
|
|
5
|
+
import { PullToRefresh } from "./pull-to-refresh.js";
|
|
6
|
+
import { mergeColors } from "@monimesl/dot-core";
|
|
7
|
+
import { useMemo, useState, useSyncExternalStore } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
//#region src/root.tsx
|
|
10
|
+
function Root({ page, dotContext, components, wrapper: Wrapper }) {
|
|
11
|
+
const theme = useSyncExternalStore(dotContext.theme.subscribe, dotContext.theme.get);
|
|
12
|
+
const systemContext = useSyncExternalStore(dotContext.systemContext.subscribe, dotContext.systemContext.get);
|
|
13
|
+
const pageColors = useSyncExternalStore(page.subscribeToColors, page.getColors);
|
|
14
|
+
const resolvedTheme = useMemo(() => resolveTheme(theme, systemContext.scheme, pageColors), [
|
|
15
|
+
theme,
|
|
16
|
+
systemContext.scheme,
|
|
17
|
+
pageColors
|
|
18
|
+
]);
|
|
19
|
+
const [rootElement, setRootElement] = useState(null);
|
|
20
|
+
const pageContent = /* @__PURE__ */ jsx(PageRoot, {
|
|
21
|
+
page,
|
|
22
|
+
components
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
25
|
+
value: resolvedTheme,
|
|
26
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
27
|
+
ref: setRootElement,
|
|
28
|
+
className: "dot-theme-root",
|
|
29
|
+
"data-dot-scheme": resolvedTheme.scheme,
|
|
30
|
+
children: /* @__PURE__ */ jsx(PortalContainerContext.Provider, {
|
|
31
|
+
value: rootElement,
|
|
32
|
+
children: /* @__PURE__ */ jsx(PullToRefresh, {
|
|
33
|
+
page,
|
|
34
|
+
children: Wrapper ? /* @__PURE__ */ jsx(Wrapper, {
|
|
35
|
+
theme: withPageColors(theme, resolvedTheme.scheme, pageColors),
|
|
36
|
+
children: pageContent
|
|
37
|
+
}) : /* @__PURE__ */ jsx(DefaultSurface, { children: pageContent })
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function withPageColors(theme, scheme, pageColors) {
|
|
44
|
+
return {
|
|
45
|
+
...theme,
|
|
46
|
+
scheme,
|
|
47
|
+
colors: {
|
|
48
|
+
...theme.colors,
|
|
49
|
+
...mergeColors(theme.colors ?? {}, pageColors)
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function DefaultSurface({ children }) {
|
|
54
|
+
const { colors } = useTheme();
|
|
55
|
+
return /* @__PURE__ */ jsx("div", {
|
|
56
|
+
className: "dot-surface",
|
|
57
|
+
style: {
|
|
58
|
+
boxSizing: "border-box",
|
|
59
|
+
minHeight: "100vh",
|
|
60
|
+
paddingBottom: HOME_INDICATOR,
|
|
61
|
+
display: "flex",
|
|
62
|
+
flexDirection: "column",
|
|
63
|
+
background: colors.background,
|
|
64
|
+
color: colors.text,
|
|
65
|
+
fontFamily: FONT_FAMILY
|
|
66
|
+
},
|
|
67
|
+
children
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { Root };
|